coverage-report

Code coverage report for All files

npmtest-webpack (v0.0.3)

Code coverage report for All files

Statements: 11.97% (1360 / 11366)      Branches: 2.37% (135 / 5693)      Functions: 2.36% (33 / 1397)      Lines: 12.63% (1357 / 10746)      Ignored: 31 statements, 1 function, 34 branches     

File Statements Branches Functions Lines
node-npmtest-webpack/ 100% (153 / 153) 100% (126 / 126) 100% (28 / 28) 100% (153 / 153)
node-npmtest-webpack/node_modules/webpack-sources/lib/ 31.35% (132 / 421) 0% (0 / 123) 1.28% (1 / 78) 32.04% (132 / 412)
node-npmtest-webpack/node_modules/webpack/buildin/ 29.73% (11 / 37) 7.69% (1 / 13) 10% (1 / 10) 31.43% (11 / 35)
node-npmtest-webpack/node_modules/webpack/hot/ 8.93% (10 / 112) 5.71% (4 / 70) 0% (0 / 23) 9.01% (10 / 111)
node-npmtest-webpack/node_modules/webpack/lib/ 8.76% (677 / 7729) 0.1% (4 / 3962) 0.31% (3 / 975) 9.28% (675 / 7272)
node-npmtest-webpack/node_modules/webpack/lib/dependencies/ 15.61% (306 / 1960) 0% (0 / 904) 0% (0 / 216) 16.22% (306 / 1886)
node-npmtest-webpack/node_modules/webpack/lib/node/ 17.19% (11 / 64) 0% (0 / 32) 0% (0 / 4) 17.19% (11 / 64)
node-npmtest-webpack/node_modules/webpack/lib/optimize/ 4.93% (39 / 791) 0% (0 / 439) 0% (0 / 54) 5.42% (39 / 720)
node-npmtest-webpack/node_modules/webpack/lib/performance/ 16% (12 / 75) 0% (0 / 18) 0% (0 / 5) 16.9% (12 / 71)
node-npmtest-webpack/node_modules/webpack/lib/util/ 50% (4 / 8) 0% (0 / 2) 100% (0 / 0) 57.14% (4 / 7)
node-npmtest-webpack/node_modules/webpack/lib/web/ 25% (1 / 4) 100% (0 / 0) 0% (0 / 2) 25% (1 / 4)
node-npmtest-webpack/node_modules/webpack/schemas/ 33.33% (4 / 12) 0% (0 / 4) 0% (0 / 2) 27.27% (3 / 11)
Code coverage report for node-npmtest-webpack/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/

Statements: 100% (153 / 153)      Branches: 100% (126 / 126)      Functions: 100% (28 / 28)      Lines: 100% (153 / 153)      Ignored: 26 statements, 1 function, 30 branches     

All files » node-npmtest-webpack/
File Statements Branches Functions Lines
example.js 100% (83 / 83) 100% (73 / 73) 100% (12 / 12) 100% (83 / 83)
lib.npmtest_webpack.js 100% (16 / 16) 100% (14 / 14) 100% (3 / 3) 100% (16 / 16)
test.js 100% (54 / 54) 100% (39 / 39) 100% (13 / 13) 100% (54 / 54)
Code coverage report for node-npmtest-webpack/example.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/example.js

Statements: 100% (83 / 83)      Branches: 100% (73 / 73)      Functions: 100% (12 / 12)      Lines: 100% (83 / 83)      Ignored: 26 statements, 1 function, 30 branches     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328                                                  2   2         2   2   2 2 2         1             2       2       2   2               1 2           2     2     2 2   1       2     1 1 1   1 1     1 1   1     1   2           1   1   1         1 2 2 3 3 3 3 1     3 3         3       1 3 1       1 1               1   1 1 1   1   1                                                                                                                                                                                       1 1                       1     6 6   1   2   1   2         1 1   1         1             1     1 1     1 1   1 1 1 1 1 1 1   1 1   1        
/*
example.js
 
quickstart example
 
instruction
    1. save this script as example.js
    2. run the shell command:
        $ npm install npmtest-webpack && PORT=8081 node example.js
    3. play with the browser-demo on http://127.0.0.1:8081
*/
 
 
 
/* istanbul instrument in package npmtest_webpack */
/*jslint
    bitwise: true,
    browser: true,
    maxerr: 8,
    maxlen: 96,
    node: true,
    nomen: true,
    regexp: true,
    stupid: true
*/
(function () {
    'use strict';
    var local;
 
 
 
    // run shared js-env code - pre-init
    (function () {
        // init local
        local = {};
        // init modeJs
        local.modeJs = (function () {
            try {
                return typeof navigator.userAgent === 'string' &&
                    typeof document.querySelector('body') === 'object' &&
                    typeof XMLHttpRequest.prototype.open === 'function' &&
                    'browser';
            } catch (errorCaughtBrowser) {
                return module.exports &&
                    typeof process.versions.node === 'string' &&
                    typeof require('http').createServer === 'function' &&
                    'node';
            }
        }());
        // init global
        local.global = local.modeJs === 'browser'
            ? window
            : global;
        // init utility2_rollup
        local = local.global.utility2_rollup || (local.modeJs === 'browser'
            ? local.global.utility2_npmtest_webpack
            : global.utility2_moduleExports);
        // export local
        local.global.local = local;
    }());
    switch (local.modeJs) {
 
 
 
    // post-init
    // run browser js-env code - post-init
    /* istanbul ignore next */
    case 'browser':
        local.testRunBrowser = function (event) {
            Eif (!event || (event &&
                    event.currentTarget &&
                    event.currentTarget.className &&
                    event.currentTarget.className.includes &&
                    event.currentTarget.className.includes('onreset'))) {
                // reset output
                Array.from(
                    document.querySelectorAll('body > .resettable')
                ).forEach(function (element) {
                    switch (element.tagName) {
                    case 'INPUT':
                    case 'TEXTAREA':
                        element.value = '';
                        break;
                    default:
                        element.textContent = '';
                    }
                });
            }
            switch (event && event.currentTarget && event.currentTarget.id) {
            case 'testRunButton1':
                // show tests
                Eif (document.querySelector('#testReportDiv1').style.display === 'none') {
                    document.querySelector('#testReportDiv1').style.display = 'block';
                    document.querySelector('#testRunButton1').textContent =
                        'hide internal test';
                    local.modeTest = true;
                    local.testRunDefault(local);
                // hide tests
                } else {
                    document.querySelector('#testReportDiv1').style.display = 'none';
                    document.querySelector('#testRunButton1').textContent = 'run internal test';
                }
                break;
            // custom-case
            default:
                break;
            }
            Iif (document.querySelector('#inputTextareaEval1') && (!event || (event &&
                    event.currentTarget &&
                    event.currentTarget.className &&
                    event.currentTarget.className.includes &&
                    event.currentTarget.className.includes('oneval')))) {
                // try to eval input-code
                try {
                    /*jslint evil: true*/
                    eval(document.querySelector('#inputTextareaEval1').value);
                } catch (errorCaught) {
                    console.error(errorCaught);
                }
            }
        };
        // log stderr and stdout to #outputTextareaStdout1
        ['error', 'log'].forEach(function (key) {
            console[key + '_original'] = console[key];
            console[key] = function () {
                var element;
                console[key + '_original'].apply(console, arguments);
                element = document.querySelector('#outputTextareaStdout1');
                Iif (!element) {
                    return;
                }
                // append text to #outputTextareaStdout1
                element.value += Array.from(arguments).map(function (arg) {
                    return typeof arg === 'string'
                        ? arg
                        : JSON.stringify(arg, null, 4);
                }).join(' ') + '\n';
                // scroll textarea to bottom
                element.scrollTop = element.scrollHeight;
            };
        });
        // init event-handling
        ['change', 'click', 'keyup'].forEach(function (event) {
            Array.from(document.querySelectorAll('.on' + event)).forEach(function (element) {
                element.addEventListener(event, local.testRunBrowser);
            });
        });
        // run tests
        local.testRunBrowser();
        break;
 
 
 
    // run node js-env code - post-init
    /* istanbul ignore next */
    case 'node':
        // export local
        module.exports = local;
        // require modules
        local.fs = require('fs');
        local.http = require('http');
        local.url = require('url');
        // init assets
        local.assetsDict = local.assetsDict || {};
        /* jslint-ignore-begin */
        local.assetsDict['/assets.index.template.html'] = '\
<!doctype html>\n\
<html lang="en">\n\
<head>\n\
<meta charset="UTF-8">\n\
<meta name="viewport" content="width=device-width, initial-scale=1">\n\
<title>{{env.npm_package_name}} (v{{env.npm_package_version}})</title>\n\
<style>\n\
/*csslint\n\
    box-sizing: false,\n\
    universal-selector: false\n\
*/\n\
* {\n\
    box-sizing: border-box;\n\
}\n\
body {\n\
    background: #dde;\n\
    font-family: Arial, Helvetica, sans-serif;\n\
    margin: 2rem;\n\
}\n\
body > * {\n\
    margin-bottom: 1rem;\n\
}\n\
.utility2FooterDiv {\n\
    margin-top: 20px;\n\
    text-align: center;\n\
}\n\
</style>\n\
<style>\n\
/*csslint\n\
*/\n\
textarea {\n\
    font-family: monospace;\n\
    height: 10rem;\n\
    width: 100%;\n\
}\n\
textarea[readonly] {\n\
    background: #ddd;\n\
}\n\
</style>\n\
</head>\n\
<body>\n\
<!-- utility2-comment\n\
<div id="ajaxProgressDiv1" style="background: #d00; height: 2px; left: 0; margin: 0; padding: 0; position: fixed; top: 0; transition: background 0.5s, width 1.5s; width: 25%;"></div>\n\
utility2-comment -->\n\
<h1>\n\
<!-- utility2-comment\n\
    <a\n\
        {{#if env.npm_package_homepage}}\n\
        href="{{env.npm_package_homepage}}"\n\
        {{/if env.npm_package_homepage}}\n\
        target="_blank"\n\
    >\n\
utility2-comment -->\n\
        {{env.npm_package_name}} (v{{env.npm_package_version}})\n\
<!-- utility2-comment\n\
    </a>\n\
utility2-comment -->\n\
</h1>\n\
<h3>{{env.npm_package_description}}</h3>\n\
<!-- utility2-comment\n\
<h4><a download href="assets.app.js">download standalone app</a></h4>\n\
<button class="onclick onreset" id="testRunButton1">run internal test</button><br>\n\
<div id="testReportDiv1" style="display: none;"></div>\n\
utility2-comment -->\n\
\n\
\n\
\n\
<label>stderr and stdout</label>\n\
<textarea class="resettable" id="outputTextareaStdout1" readonly></textarea>\n\
<!-- utility2-comment\n\
{{#if isRollup}}\n\
<script src="assets.app.js"></script>\n\
{{#unless isRollup}}\n\
utility2-comment -->\n\
<script src="assets.utility2.rollup.js"></script>\n\
<script src="jsonp.utility2._stateInit?callback=window.utility2._stateInit"></script>\n\
<script src="assets.npmtest_webpack.rollup.js"></script>\n\
<script src="assets.example.js"></script>\n\
<script src="assets.test.js"></script>\n\
<!-- utility2-comment\n\
{{/if isRollup}}\n\
utility2-comment -->\n\
<div class="utility2FooterDiv">\n\
    [ this app was created with\n\
    <a href="https://github.com/kaizhu256/node-utility2" target="_blank">utility2</a>\n\
    ]\n\
</div>\n\
</body>\n\
</html>\n\
';
        /* jslint-ignore-end */
        Iif (local.templateRender) {
            local.assetsDict['/'] = local.templateRender(
                local.assetsDict['/assets.index.template.html'],
                {
                    env: local.objectSetDefault(local.env, {
                        npm_package_description: 'the greatest app in the world!',
                        npm_package_name: 'my-app',
                        npm_package_nameAlias: 'my_app',
                        npm_package_version: '0.0.1'
                    })
                }
            );
        } else {
            local.assetsDict['/'] = local.assetsDict['/assets.index.template.html']
                .replace((/\{\{env\.(\w+?)\}\}/g), function (match0, match1) {
                    // jslint-hack
                    String(match0);
                    switch (match1) {
                    case 'npm_package_description':
                        return 'the greatest app in the world!';
                    case 'npm_package_name':
                        return 'my-app';
                    case 'npm_package_nameAlias':
                        return 'my_app';
                    case 'npm_package_version':
                        return '0.0.1';
                    }
                });
        }
        // run the cli
        Eif (local.global.utility2_rollup || module !== require.main) {
            break;
        }
        local.assetsDict['/assets.example.js'] =
            local.assetsDict['/assets.example.js'] ||
            local.fs.readFileSync(__filename, 'utf8');
        // bug-workaround - long $npm_package_buildCustomOrg
        /* jslint-ignore-begin */
        local.assetsDict['/assets.npmtest_webpack.rollup.js'] =
            local.assetsDict['/assets.npmtest_webpack.rollup.js'] ||
            local.fs.readFileSync(
                local.npmtest_webpack.__dirname + '/lib.npmtest_webpack.js',
                'utf8'
            ).replace((/^#!/), '//');
        /* jslint-ignore-end */
        local.assetsDict['/favicon.ico'] = local.assetsDict['/favicon.ico'] || '';
        // if $npm_config_timeout_exit exists,
        // then exit this process after $npm_config_timeout_exit ms
        if (Number(process.env.npm_config_timeout_exit)) {
            setTimeout(process.exit, Number(process.env.npm_config_timeout_exit));
        }
        // start server
        if (local.global.utility2_serverHttp1) {
            break;
        }
        process.env.PORT = process.env.PORT || '8081';
        console.error('server starting on port ' + process.env.PORT);
        local.http.createServer(function (request, response) {
            request.urlParsed = local.url.parse(request.url);
            if (local.assetsDict[request.urlParsed.pathname] !== undefined) {
                response.end(local.assetsDict[request.urlParsed.pathname]);
                return;
            }
            response.statusCode = 404;
            response.end();
        }).listen(process.env.PORT);
        break;
    }
}());
 
 
Code coverage report for node-npmtest-webpack/lib.npmtest_webpack.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/lib.npmtest_webpack.js

Statements: 100% (16 / 16)      Branches: 100% (14 / 14)      Functions: 100% (3 / 3)      Lines: 100% (16 / 16)      Ignored: none     

All files » node-npmtest-webpack/ » lib.npmtest_webpack.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55                      2   2         2   2   2 2 2         1             2       2   2   2 1   1 1 1          
/* istanbul instrument in package npmtest_webpack */
/*jslint
    bitwise: true,
    browser: true,
    maxerr: 8,
    maxlen: 96,
    node: true,
    nomen: true,
    regexp: true,
    stupid: true
*/
(function () {
    'use strict';
    var local;
 
 
 
    // run shared js-env code - pre-init
    (function () {
        // init local
        local = {};
        // init modeJs
        local.modeJs = (function () {
            try {
                return typeof navigator.userAgent === 'string' &&
                    typeof document.querySelector('body') === 'object' &&
                    typeof XMLHttpRequest.prototype.open === 'function' &&
                    'browser';
            } catch (errorCaughtBrowser) {
                return module.exports &&
                    typeof process.versions.node === 'string' &&
                    typeof require('http').createServer === 'function' &&
                    'node';
            }
        }());
        // init global
        local.global = local.modeJs === 'browser'
            ? window
            : global;
        // init utility2_rollup
        local = local.global.utility2_rollup || local;
        // init lib
        local.local = local.npmtest_webpack = local;
        // init exports
        if (local.modeJs === 'browser') {
            local.global.utility2_npmtest_webpack = local;
        } else {
            module.exports = local;
            module.exports.__dirname = __dirname;
            module.exports.module = module;
        }
    }());
}());
 
 
Code coverage report for node-npmtest-webpack/test.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/test.js

Statements: 100% (54 / 54)      Branches: 100% (39 / 39)      Functions: 100% (13 / 13)      Lines: 100% (54 / 54)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197                      2   2         2   2   2 2 2         1             2     2     1       1     1   1     2           2 2   2           1           1           2 2   2           1             1       1     1             1             1 1     1             1 1 1 1 1 1     1         2 2     1             2 2     1             2 2     1             2 2     1             1 1       1 1        
/* istanbul instrument in package npmtest_webpack */
/*jslint
    bitwise: true,
    browser: true,
    maxerr: 8,
    maxlen: 96,
    node: true,
    nomen: true,
    regexp: true,
    stupid: true
*/
(function () {
    'use strict';
    var local;
 
 
 
    // run shared js-env code - pre-init
    (function () {
        // init local
        local = {};
        // init modeJs
        local.modeJs = (function () {
            try {
                return typeof navigator.userAgent === 'string' &&
                    typeof document.querySelector('body') === 'object' &&
                    typeof XMLHttpRequest.prototype.open === 'function' &&
                    'browser';
            } catch (errorCaughtBrowser) {
                return module.exports &&
                    typeof process.versions.node === 'string' &&
                    typeof require('http').createServer === 'function' &&
                    'node';
            }
        }());
        // init global
        local.global = local.modeJs === 'browser'
            ? window
            : global;
        switch (local.modeJs) {
        // re-init local from window.local
        case 'browser':
            local = local.global.utility2.objectSetDefault(
                local.global.utility2_rollup || local.global.local,
                local.global.utility2
            );
            break;
        // re-init local from example.js
        case 'node':
            local = (local.global.utility2_rollup || require('utility2'))
                .requireExampleJsFromReadme();
            break;
        }
        // export local
        local.global.local = local;
    }());
 
 
 
    // run shared js-env code - function
    (function () {
        return;
    }());
    switch (local.modeJs) {
 
 
 
    // run browser js-env code - function
    case 'browser':
        break;
 
 
 
    // run node js-env code - function
    case 'node':
        break;
    }
 
 
 
    // run shared js-env code - post-init
    (function () {
        return;
    }());
    switch (local.modeJs) {
 
 
 
    // run browser js-env code - post-init
    case 'browser':
        local.testCase_browser_nullCase = local.testCase_browser_nullCase || function (
            options,
            onError
        ) {
        /*
         * this function will test browsers's null-case handling-behavior-behavior
         */
            onError(null, options);
        };
 
        // run tests
        local.nop(local.modeTest &&
            document.querySelector('#testRunButton1') &&
            document.querySelector('#testRunButton1').click());
        break;
 
 
 
    // run node js-env code - post-init
    /* istanbul ignore next */
    case 'node':
        local.testCase_buildApidoc_default = local.testCase_buildApidoc_default || function (
            options,
            onError
        ) {
        /*
         * this function will test buildApidoc's default handling-behavior-behavior
         */
            options = { modulePathList: module.paths };
            local.buildApidoc(options, onError);
        };
 
        local.testCase_buildApp_default = local.testCase_buildApp_default || function (
            options,
            onError
        ) {
        /*
         * this function will test buildApp's default handling-behavior-behavior
         */
            local.testCase_buildReadme_default(options, local.onErrorThrow);
            local.testCase_buildLib_default(options, local.onErrorThrow);
            local.testCase_buildTest_default(options, local.onErrorThrow);
            local.testCase_buildCustomOrg_default(options, local.onErrorThrow);
            options = [];
            local.buildApp(options, onError);
        };
 
        local.testCase_buildCustomOrg_default = local.testCase_buildCustomOrg_default ||
            function (options, onError) {
            /*
             * this function will test buildCustomOrg's default handling-behavior
             */
                options = {};
                local.buildCustomOrg(options, onError);
            };
 
        local.testCase_buildLib_default = local.testCase_buildLib_default || function (
            options,
            onError
        ) {
        /*
         * this function will test buildLib's default handling-behavior
         */
            options = {};
            local.buildLib(options, onError);
        };
 
        local.testCase_buildReadme_default = local.testCase_buildReadme_default || function (
            options,
            onError
        ) {
        /*
         * this function will test buildReadme's default handling-behavior-behavior
         */
            options = {};
            local.buildReadme(options, onError);
        };
 
        local.testCase_buildTest_default = local.testCase_buildTest_default || function (
            options,
            onError
        ) {
        /*
         * this function will test buildTest's default handling-behavior
         */
            options = {};
            local.buildTest(options, onError);
        };
 
        local.testCase_webpage_default = local.testCase_webpage_default || function (
            options,
            onError
        ) {
        /*
         * this function will test webpage's default handling-behavior
         */
            options = { modeCoverageMerge: true, url: local.serverLocalHost + '?modeTest=1' };
            local.browserTest(options, onError);
        };
 
        // run test-server
        local.testRunServer(local);
        break;
    }
}());
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/

Statements: 31.35% (132 / 421)      Branches: 0% (0 / 123)      Functions: 1.28% (1 / 78)      Lines: 32.04% (132 / 412)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack-sources/lib/
File Statements Branches Functions Lines
CachedSource.js 16.28% (7 / 43) 0% (0 / 22) 0% (0 / 8) 18.42% (7 / 38)
ConcatSource.js 40% (14 / 35) 0% (0 / 10) 0% (0 / 13) 40% (14 / 35)
LineToLineMappedSource.js 46.43% (13 / 28) 0% (0 / 2) 0% (0 / 6) 46.43% (13 / 28)
OriginalSource.js 28.3% (15 / 53) 0% (0 / 19) 0% (0 / 9) 28.85% (15 / 52)
PrefixSource.js 30.23% (13 / 43) 0% (0 / 12) 0% (0 / 8) 31.71% (13 / 41)
RawSource.js 63.16% (12 / 19) 100% (0 / 0) 0% (0 / 6) 63.16% (12 / 19)
ReplaceSource.js 16% (20 / 125) 0% (0 / 38) 0% (0 / 15) 16.13% (20 / 124)
Source.js 68.75% (11 / 16) 0% (0 / 2) 0% (0 / 5) 68.75% (11 / 16)
SourceAndMapMixin.js 25% (3 / 12) 0% (0 / 8) 33.33% (1 / 3) 25% (3 / 12)
SourceMapSource.js 39.47% (15 / 38) 0% (0 / 10) 0% (0 / 5) 39.47% (15 / 38)
index.js 100% (9 / 9) 100% (0 / 0) 100% (0 / 0) 100% (9 / 9)
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/CachedSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/CachedSource.js

Statements: 16.28% (7 / 43)      Branches: 0% (0 / 22)      Functions: 0% (0 / 8)      Lines: 18.42% (7 / 38)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72        1                           1   1         1             1                                                     1               1        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
function CachedSource(source) {
	this._source = source;
	this._cachedSource = undefined;
	this._cachedSize = undefined;
	this._cachedMaps = {};
 
	if(source.node) this.node = function(options) {
		return this._source.node(options);
	};
 
	if(source.listMap) this.listMap = function(options) {
		return this._source.listMap(options);
	};
}
module.exports = CachedSource;
 
CachedSource.prototype.source = function() {
	if(typeof this._cachedSource !== "undefined") return this._cachedSource;
	return this._cachedSource = this._source.source();
};
 
CachedSource.prototype.size = function() {
	if(typeof this._cachedSize !== "undefined") return this._cachedSize;
	if(typeof this._cachedSource !== "undefined")
		return this._cachedSize = this._cachedSource.length;
	return this._cachedSize = this._source.size();
};
 
CachedSource.prototype.sourceAndMap = function(options) {
	var key = JSON.stringify(options);
	if(typeof this._cachedSource !== "undefined" && key in this._cachedMaps)
		return {
			source: this._cachedSource,
			map: this._cachedMaps[key]
		};
	else if(typeof this._cachedSource !== "undefined") {
		return {
			source: this._cachedSource,
			map: this._cachedMaps[key] = this._source.map(options)
		};
	} else if(key in this._cachedMaps) {
		return {
			source: this._cachedSource = this._source.source(),
			map: this._cachedMaps[key]
		};
	}
	var result = this._source.sourceAndMap(options);
	this._cachedSource = result.source;
	this._cachedMaps[key] = result.map;
	return {
		source: this._cachedSource,
		map: this._cachedMaps[key]
	};
};
 
CachedSource.prototype.map = function(options) {
	if(!options) options = {};
	var key = JSON.stringify(options);
	if(key in this._cachedMaps)
		return this._cachedMaps[key];
	return this._cachedMaps[key] = this._source.map();
};
 
CachedSource.prototype.updateHash = function(hash) {
	this._source.updateHash(hash);
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/ConcatSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/ConcatSource.js

Statements: 40% (14 / 35)      Branches: 0% (0 / 10)      Functions: 0% (0 / 13)      Lines: 40% (14 / 35)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65        1 1 1   1       1   1 1   1       1           1               1   1             1                     1                  
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var SourceNode = require("source-map").SourceNode;
var SourceListMap = require("source-list-map").SourceListMap;
var Source = require("./Source");
 
function ConcatSource() {
	Source.call(this);
	this.children = Array.prototype.slice.call(arguments);
}
module.exports = ConcatSource;
 
ConcatSource.prototype = Object.create(Source.prototype);
ConcatSource.prototype.constructor = ConcatSource;
 
ConcatSource.prototype.add = function(item) {
	this.children.push(item);
};
 
ConcatSource.prototype.source = function() {
	return this.children.map(function(item) {
		return typeof item === "string" ? item : item.source();
	}).join("");
};
 
ConcatSource.prototype.size = function() {
	return this.children.map(function(item) {
		return typeof item === "string" ? item.length : item.size();
	}).reduce(function(sum, s) {
		return sum + s;
	}, 0);
};
 
require("./SourceAndMapMixin")(ConcatSource.prototype);
 
ConcatSource.prototype.node = function(options) {
	var node = new SourceNode(null, null, null, this.children.map(function(item) {
		return typeof item === "string" ? item : item.node(options);
	}));
	return node;
};
 
ConcatSource.prototype.listMap = function(options) {
	var map = new SourceListMap();
	this.children.forEach(function(item) {
		if(typeof item === "string")
			map.add(item);
		else
			map.add(item.listMap(options));
	});
	return map;
};
 
ConcatSource.prototype.updateHash = function(hash) {
	this.children.forEach(function(item) {
		if(typeof item === "string")
			hash.update(item);
		else
			item.updateHash(hash);
	});
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/LineToLineMappedSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/LineToLineMappedSource.js

Statements: 46.43% (13 / 28)      Branches: 0% (0 / 2)      Functions: 0% (0 / 6)      Lines: 46.43% (13 / 28)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50        1 1 1 1   1             1   1 1   1       1   1                         1       1          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var SourceListMap = require("source-list-map").SourceListMap;
var Source = require("./Source");
 
function LineToLineMappedSource(value, name, originalSource) {
	Source.call(this);
	this._value = value;
	this._name = name;
	this._originalSource = originalSource;
}
 
module.exports = LineToLineMappedSource;
 
LineToLineMappedSource.prototype = Object.create(Source.prototype);
LineToLineMappedSource.prototype.constructor = LineToLineMappedSource;
 
LineToLineMappedSource.prototype.source = function() {
	return this._value;
};
 
require("./SourceAndMapMixin")(LineToLineMappedSource.prototype);
 
LineToLineMappedSource.prototype.node = function(options) {
	var value = this._value;
	var name = this._name;
	var lines = value.split("\n");
	var node = new SourceNode(null, null, null,
		lines.map(function(line, idx) {
			return new SourceNode(idx + 1, 0, name, (line + (idx != lines.length - 1 ? "\n" : "")));
		})
	);
	node.setSourceContent(name, this._originalSource);
	return node;
};
 
LineToLineMappedSource.prototype.listMap = function(options) {
	return new SourceListMap(this._value, this._name, this._originalSource)
};
 
LineToLineMappedSource.prototype.updateHash = function(hash) {
	hash.update(this._value);
	hash.update(this._originalSource);
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/OriginalSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/OriginalSource.js

Statements: 28.3% (15 / 53)      Branches: 0% (0 / 19)      Functions: 0% (0 / 9)      Lines: 28.85% (15 / 52)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90        1 1 1 1   1                       1                               1           1   1 1   1       1   1                                                     1       1        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var SourceListMap = require("source-list-map").SourceListMap;
var Source = require("./Source");
 
function isSplitter(c) {
	switch(c) {
		case 10: // \n
		case 13: // \r
		case 59: // ;
		case 123: // {
		case 125: // }
			return true;
	}
	return false;
}
 
function _splitCode(code) {
	var result = [];
	var i = 0;
	var j = 0;
	for(; i < code.length; i++) {
		if(isSplitter(code.charCodeAt(i))) {
			while(isSplitter(code.charCodeAt(++i)));
			result.push(code.substring(j, i));
			j = i;
		}
	}
	if(j < code.length)
		result.push(code.substr(j));
	return result;
}
 
function OriginalSource(value, name) {
	Source.call(this);
	this._value = value;
	this._name = name;
}
 
module.exports = OriginalSource;
 
OriginalSource.prototype = Object.create(Source.prototype);
OriginalSource.prototype.constructor = OriginalSource;
 
OriginalSource.prototype.source = function() {
	return this._value;
};
 
require("./SourceAndMapMixin")(OriginalSource.prototype);
 
OriginalSource.prototype.node = function(options) {
	options = options || {};
	var sourceMap = this._sourceMap;
	var value = this._value;
	var name = this._name;
	var lines = value.split("\n");
	var node = new SourceNode(null, null, null,
		lines.map(function(line, idx) {
			var pos = 0;
			if(options.columns === false) {
				var content = line + (idx != lines.length - 1 ? "\n" : "");
				return new SourceNode(idx + 1, 0, name, content);
			}
			return new SourceNode(null, null, null,
				_splitCode(line + (idx != lines.length - 1 ? "\n" : "")).map(function(item) {
					if(/^\s*$/.test(item)) return item;
					var res = new SourceNode(idx + 1, pos, name, item);
					pos += item.length;
					return res;
				})
			);
		})
	);
	node.setSourceContent(name, value);
	return node;
};
 
OriginalSource.prototype.listMap = function(options) {
	return new SourceListMap(this._value, this._name, this._value)
};
 
OriginalSource.prototype.updateHash = function(hash) {
	hash.update(this._value);
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/PrefixSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/PrefixSource.js

Statements: 30.23% (13 / 43)      Branches: 0% (0 / 12)      Functions: 0% (0 / 8)      Lines: 31.71% (13 / 41)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76        1 1   1   1         1   1 1   1           1   1               1               1                     1                                          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var Source = require("./Source");
var SourceNode = require("source-map").SourceNode;
 
var REPLACE_REGEX = /\n(?=.|\s)/g
 
function PrefixSource(prefix, source) {
	Source.call(this);
	this._source = source;
	this._prefix = prefix;
}
module.exports = PrefixSource;
 
PrefixSource.prototype = Object.create(Source.prototype);
PrefixSource.prototype.constructor = PrefixSource;
 
PrefixSource.prototype.source = function() {
	var node = typeof this._source === "string" ? this._source : this._source.source();
	var prefix = this._prefix;
	return prefix + node.replace(REPLACE_REGEX, "\n" + prefix);
};
 
require("./SourceAndMapMixin")(PrefixSource.prototype);
 
PrefixSource.prototype.node = function(options) {
	var node = this._source.node(options);
	var append = [this._prefix];
	return new SourceNode(null, null, null, [
		cloneAndPrefix(node, this._prefix, append)
	]);
};
 
PrefixSource.prototype.listMap = function(options) {
	var prefix = this._prefix;
	var map = this._source.listMap(options);
	return map.mapGeneratedCode(function(code) {
		return prefix + code.replace(REPLACE_REGEX, "\n" + prefix);
	});
};
 
PrefixSource.prototype.updateHash = function(hash) {
	if(typeof this._source === "string")
		hash.update(this._source);
	else
		this._source.updateHash(hash);
	if(typeof this._prefix === "string")
		hash.update(this._prefix);
	else
		this._prefix.updateHash(hash);
};
 
function cloneAndPrefix(node, prefix, append) {
	if(typeof node === "string") {
		var result = node.replace(REPLACE_REGEX, "\n" + prefix);
		if(append.length > 0) result = append.pop() + result;
		if(/\n$/.test(node)) append.push(prefix);
		return result;
	} else {
		var newNode = new SourceNode(
			node.line,
			node.column,
			node.source,
			node.children.map(function(node) {
				return cloneAndPrefix(node, prefix, append);
			}),
			node.name
		);
		newNode.sourceContents = node.sourceContents;
		return newNode;
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/RawSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/RawSource.js

Statements: 63.16% (12 / 19)      Branches: 100% (0 / 0)      Functions: 0% (0 / 6)      Lines: 63.16% (12 / 19)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38        1 1 1   1       1   1 1   1       1       1       1       1        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var Source = require("./Source");
var SourceNode = require("source-map").SourceNode;
var SourceListMap = require("source-list-map").SourceListMap;
 
function RawSource(value) {
	Source.call(this);
	this._value = value;
}
module.exports = RawSource;
 
RawSource.prototype = Object.create(Source.prototype);
RawSource.prototype.constructor = RawSource;
 
RawSource.prototype.source = function() {
	return this._value;
};
 
RawSource.prototype.map = function(options) {
	return null;
};
 
RawSource.prototype.node = function(options) {
	return new SourceNode(null, null, null, this._value);
};
 
RawSource.prototype.listMap = function(options) {
	return new SourceListMap(this._value);
};
 
RawSource.prototype.updateHash = function(hash) {
	hash.update(this._value);
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/ReplaceSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/ReplaceSource.js

Statements: 16% (20 / 125)      Branches: 0% (0 / 38)      Functions: 0% (0 / 15)      Lines: 16.13% (20 / 124)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194        1 1 1 1 1   1           1   1 1   1           1           1       1                       1                             1   1                                                     1                                                                                                       1                             1                                                         1        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var Source = require("./Source");
var SourceNode = require("source-map").SourceNode;
var SourceListMap = require("source-list-map").SourceListMap;
var fromStringWithSourceMap = require("source-list-map").fromStringWithSourceMap;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
 
function ReplaceSource(source, name) {
	Source.call(this);
	this._source = source;
	this._name = name;
	this.replacements = [];
}
module.exports = ReplaceSource;
 
ReplaceSource.prototype = Object.create(Source.prototype);
ReplaceSource.prototype.constructor = ReplaceSource;
 
ReplaceSource.prototype.replace = function(start, end, newValue) {
	if(typeof newValue !== "string")
		throw new Error("insertion must be a string, but is a " + typeof newValue);
	this.replacements.push([start, end, newValue, this.replacements.length]);
};
 
ReplaceSource.prototype.insert = function(pos, newValue) {
	if(typeof newValue !== "string")
		throw new Error("insertion must be a string, but is a " + typeof newValue + ": " + newValue);
	this.replacements.push([pos, pos - 1, newValue, this.replacements.length]);
};
 
ReplaceSource.prototype.source = function(options) {
	return this._replaceString(this._source.source());
};
 
ReplaceSource.prototype._sortReplacements = function() {
	this.replacements.sort(function(a, b) {
		var diff = b[1] - a[1];
		if(diff !== 0)
			return diff;
		diff = b[0] - a[0];
		if(diff !== 0)
			return diff;
		return b[3] - a[3];
	});
};
 
ReplaceSource.prototype._replaceString = function(str) {
	if(typeof str !== "string")
		throw new Error("str must be a string, but is a " + typeof str + ": " + str);
	this._sortReplacements();
	var result = [str];
	this.replacements.forEach(function(repl) {
		var remSource = result.pop();
		var splitted1 = this._splitString(remSource, Math.floor(repl[1] + 1));
		var splitted2 = this._splitString(splitted1[0], Math.floor(repl[0]));
		result.push(splitted1[1], repl[2], splitted2[0]);
	}, this);
	result = result.reverse();
	return result.join("");
};
 
require("./SourceAndMapMixin")(ReplaceSource.prototype);
 
ReplaceSource.prototype.node = function(options) {
	this._sortReplacements();
	var result = [this._source.node(options)];
	this.replacements.forEach(function(repl) {
		var remSource = result.pop();
		var splitted1 = this._splitSourceNode(remSource, Math.floor(repl[1] + 1));
		var splitted2;
		if(Array.isArray(splitted1)) {
			splitted2 = this._splitSourceNode(splitted1[0], Math.floor(repl[0]));
			if(Array.isArray(splitted2)) {
				result.push(splitted1[1], this._replacementToSourceNode(splitted2[1], repl[2]), splitted2[0]);
			} else {
				result.push(splitted1[1], this._replacementToSourceNode(splitted1[1], repl[2]), splitted1[0]);
			}
		} else {
			splitted2 = this._splitSourceNode(remSource, Math.floor(repl[0]));
			if(Array.isArray(splitted2)) {
				result.push(this._replacementToSourceNode(splitted2[1], repl[2]), splitted2[0]);
			} else {
				result.push(repl[2], remSource);
			}
		}
	}, this);
	result = result.reverse();
	return new SourceNode(null, null, null, result);
};
 
ReplaceSource.prototype.listMap = function(options) {
	this._sortReplacements();
	var map = this._source.listMap(options);
	var currentIndex = 0;
	var replacements = this.replacements;
	var idxReplacement = replacements.length - 1;
	var removeChars = 0;
	map = map.mapGeneratedCode(function(str) {
		var newCurrentIndex = currentIndex + str.length;
		if(removeChars > str.length) {
			removeChars -= str.length;
			str = "";
		} else {
			if(removeChars > 0) {
				str = str.substr(removeChars);
				currentIndex += removeChars;
				removeChars = 0;
			}
			var finalStr = "";
			while(idxReplacement >= 0 && replacements[idxReplacement][0] < newCurrentIndex) {
				var repl = replacements[idxReplacement];
				var start = Math.floor(repl[0]);
				var end = Math.floor(repl[1] + 1);
				var before = str.substr(0, Math.max(0, start - currentIndex));
				if(end <= newCurrentIndex) {
					var after = str.substr(Math.max(0, end - currentIndex));
					finalStr += before + repl[2];
					str = after;
					currentIndex = Math.max(currentIndex, end);
				} else {
					finalStr += before + repl[2];
					str = "";
					removeChars = end - newCurrentIndex;
				}
				idxReplacement--;
			}
			str = finalStr + str;
		}
		currentIndex = newCurrentIndex;
		return str;
	});
	var extraCode = "";
	while(idxReplacement >= 0) {
		extraCode += replacements[idxReplacement][2];
		idxReplacement--;
	}
	if(extraCode) {
		map.add(extraCode);
	}
	return map;
};
 
ReplaceSource.prototype._replacementToSourceNode = function(oldNode, newString) {
	var map = oldNode.toStringWithSourceMap({
		file: "?"
	}).map;
	var original = new SourceMapConsumer(map.toJSON()).originalPositionFor({
		line: 1,
		column: 0
	});
	if(original) {
		return new SourceNode(original.line, original.column, original.source, newString);
	} else {
		return newString;
	}
};
 
ReplaceSource.prototype._splitSourceNode = function(node, position) {
	if(typeof node === "string") {
		if(node.length <= position) return position - node.length;
		return position <= 0 ? ["", node] : [node.substr(0, position), node.substr(position)];
	} else {
		for(var i = 0; i < node.children.length; i++) {
			position = this._splitSourceNode(node.children[i], position);
			if(Array.isArray(position)) {
				var leftNode = new SourceNode(
					node.line,
					node.column,
					node.source,
					node.children.slice(0, i).concat([position[0]]),
					node.name
				);
				var rightNode = new SourceNode(
					node.line,
					node.column,
					node.source, [position[1]].concat(node.children.slice(i + 1)),
					node.name
				);
				leftNode.sourceContents = node.sourceContents;
				return [leftNode, rightNode];
			}
		}
		return position;
	}
};
 
ReplaceSource.prototype._splitString = function(str, position) {
	return position <= 0 ? ["", str] : [str.substr(0, position), str.substr(position)];
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/Source.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/Source.js

Statements: 68.75% (11 / 16)      Branches: 0% (0 / 2)      Functions: 0% (0 / 5)      Lines: 68.75% (11 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38        1 1   1   1   1   1       1       1             1   1   1          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
 
function Source() {}
 
module.exports = Source;
 
Source.prototype.source = null;
 
Source.prototype.size = function() {
	return this.source().length;
};
 
Source.prototype.map = function(options) {
	return null;
};
 
Source.prototype.sourceAndMap = function(options) {
	return {
		source: this.source(),
		map: this.map()
	};
};
 
Source.prototype.node = null;
 
Source.prototype.listNode = null;
 
Source.prototype.updateHash = function(hash) {
	var source = this.source();
	hash.update(source || "");
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/SourceAndMapMixin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/SourceAndMapMixin.js

Statements: 25% (3 / 12)      Branches: 0% (0 / 8)      Functions: 33.33% (1 / 3)      Lines: 25% (3 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38        1 6                         6                                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
module.exports = function mixinSourceAndMap(proto) {
	proto.map = function(options) {
		options = options || {};
		if(options.columns === false) {
			return this.listMap(options).toStringWithSourceMap({
				file: "x"
			}).map;
		}
 
		return this.node(options).toStringWithSourceMap({
			file: "x"
		}).map.toJSON();
	};
 
	proto.sourceAndMap = function(options) {
		options = options || {};
		if(options.columns === false) {
			//console.log(this.listMap(options).debugInfo());
			return this.listMap(options).toStringWithSourceMap({
				file: "x"
			});
		}
 
		var res = this.node(options).toStringWithSourceMap({
			file: "x"
		});
		return {
			source: res.code,
			map: res.map.toJSON()
		};
	};
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/SourceMapSource.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/SourceMapSource.js

Statements: 39.47% (15 / 38)      Branches: 0% (0 / 10)      Functions: 0% (0 / 5)      Lines: 39.47% (15 / 38)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57        1 1 1 1 1 1   1               1   1 1   1       1   1                           1           1            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var SourceNode = require("source-map").SourceNode;
var SourceMapConsumer = require("source-map").SourceMapConsumer;
var SourceMapGenerator = require("source-map").SourceMapGenerator;
var SourceListMap = require("source-list-map").SourceListMap;
var fromStringWithSourceMap = require("source-list-map").fromStringWithSourceMap;
var Source = require("./Source");
 
function SourceMapSource(value, name, sourceMap, originalSource, innerSourceMap) {
	Source.call(this);
	this._value = value;
	this._name = name;
	this._sourceMap = sourceMap;
	this._originalSource = originalSource;
	this._innerSourceMap = innerSourceMap;
}
module.exports = SourceMapSource;
 
SourceMapSource.prototype = Object.create(Source.prototype);
SourceMapSource.prototype.constructor = SourceMapSource;
 
SourceMapSource.prototype.source = function() {
	return this._value;
};
 
require("./SourceAndMapMixin")(SourceMapSource.prototype);
 
SourceMapSource.prototype.node = function(options) {
	var innerSourceMap = this._innerSourceMap;
	var sourceMap = this._sourceMap;
	if(innerSourceMap) {
		sourceMap = SourceMapGenerator.fromSourceMap(new SourceMapConsumer(sourceMap));
		if(this._originalSource)
			sourceMap.setSourceContent(this._name, this._originalSource);
		innerSourceMap = new SourceMapConsumer(innerSourceMap);
		sourceMap.applySourceMap(innerSourceMap, this._name);
		sourceMap = sourceMap.toJSON();
	}
	return SourceNode.fromStringWithSourceMap(this._value, new SourceMapConsumer(sourceMap));
};
 
SourceMapSource.prototype.listMap = function(options) {
	if(options.module === false)
		return new SourceListMap(this._value, this._name, this._value);
	return fromStringWithSourceMap(this._value, typeof this._sourceMap === "string" ? JSON.parse(this._sourceMap) : this._sourceMap);
};
 
SourceMapSource.prototype.updateHash = function(hash) {
	hash.update(this._value);
	if(this._originalSource)
		hash.update(this._originalSource);
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/index.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack-sources/lib/index.js

Statements: 100% (9 / 9)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (9 / 9)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17        1   1 1 1 1   1 1 1 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
exports.Source = require("./Source");
 
exports.RawSource = require("./RawSource");
exports.OriginalSource = require("./OriginalSource");
exports.SourceMapSource = require("./SourceMapSource");
exports.LineToLineMappedSource = require("./LineToLineMappedSource");
 
exports.CachedSource = require("./CachedSource");
exports.ConcatSource = require("./ConcatSource");
exports.ReplaceSource = require("./ReplaceSource");
exports.PrefixSource = require("./PrefixSource");
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/

Statements: 29.73% (11 / 37)      Branches: 7.69% (1 / 13)      Functions: 10% (1 / 10)      Lines: 31.43% (11 / 35)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/buildin/
File Statements Branches Functions Lines
amd-define.js 50% (1 / 2) 100% (0 / 0) 0% (0 / 1) 50% (1 / 2)
amd-options.js 100% (1 / 1) 100% (0 / 0) 100% (0 / 0) 100% (1 / 1)
global.js 75% (6 / 8) 20% (1 / 5) 100% (1 / 1) 75% (6 / 8)
harmony-module.js 8.33% (1 / 12) 0% (0 / 4) 0% (0 / 3) 9.09% (1 / 11)
module.js 8.33% (1 / 12) 0% (0 / 4) 0% (0 / 4) 9.09% (1 / 11)
system.js 50% (1 / 2) 100% (0 / 0) 0% (0 / 1) 50% (1 / 2)
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/amd-define.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/amd-define.js

Statements: 50% (1 / 2)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 50% (1 / 2)      Ignored: none     

1 2 3 4 51        
module.exports = function() {
	throw new Error("define cannot be used indirect");
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/amd-options.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/amd-options.js

Statements: 100% (1 / 1)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (1 / 1)      Ignored: none     

1 2 3 4  2    
/* globals __webpack_amd_options__ */
module.exports = __webpack_amd_options__;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/global.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/global.js

Statements: 75% (6 / 8)      Branches: 20% (1 / 5)      Functions: 100% (1 / 1)      Lines: 75% (6 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 231     1 1     1   1                     1    
var g;
 
// This works in non-strict mode
g = (function() {
	return this;
})();
 
try {
	// This works if eval is allowed (see CSP)
	g = g || Function("return this")() || (1,eval)("this");
} catch(e) {
	// This works if the window reference is available
	if(typeof window === "object")
		g = window;
}
 
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
 
module.exports = g;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/harmony-module.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/harmony-module.js

Statements: 8.33% (1 / 12)      Branches: 0% (0 / 4)      Functions: 0% (0 / 3)      Lines: 9.09% (1 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261                                                  
module.exports = function(originalModule) {
	if(!originalModule.webpackPolyfill) {
		var module = Object.create(originalModule);
		// module.parent = undefined by default
		if(!module.children) module.children = [];
		Object.defineProperty(module, "loaded", {
			enumerable: true,
			get: function() {
				return module.l;
			}
		});
		Object.defineProperty(module, "id", {
			enumerable: true,
			get: function() {
				return module.i;
			}
		});
		Object.defineProperty(module, "exports", {
			enumerable: true,
		});
		module.webpackPolyfill = 1;
	}
	return module;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/module.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/module.js

Statements: 8.33% (1 / 12)      Branches: 0% (0 / 4)      Functions: 0% (0 / 4)      Lines: 9.09% (1 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241                                              
module.exports = function(module) {
	if(!module.webpackPolyfill) {
		module.deprecate = function() {};
		module.paths = [];
		// module.parent = undefined by default
		if(!module.children) module.children = [];
		Object.defineProperty(module, "loaded", {
			enumerable: true,
			get: function() {
				return module.l;
			}
		});
		Object.defineProperty(module, "id", {
			enumerable: true,
			get: function() {
				return module.i;
			}
		});
		module.webpackPolyfill = 1;
	}
	return module;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/system.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/buildin/system.js

Statements: 50% (1 / 2)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 50% (1 / 2)      Ignored: none     

1 2 3 4 5 6 7 8 9  1              
// Provide a "System" global.
module.exports = {
	// Make sure import is only used as "System.import"
	import: function() {
		throw new Error("System.import cannot be used indirectly");
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/

Statements: 8.93% (10 / 112)      Branches: 5.71% (4 / 70)      Functions: 0% (0 / 23)      Lines: 9.01% (10 / 111)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/hot/
File Statements Branches Functions Lines
dev-server.js 6.67% (2 / 30) 5.56% (1 / 18) 0% (0 / 5) 6.67% (2 / 30)
emitter.js 100% (2 / 2) 100% (0 / 0) 100% (0 / 0) 100% (2 / 2)
only-dev-server.js 5.56% (2 / 36) 5% (1 / 20) 0% (0 / 9) 5.56% (2 / 36)
poll.js 10.53% (2 / 19) 6.25% (1 / 16) 0% (0 / 3) 11.11% (2 / 18)
signal.js 8% (2 / 25) 6.25% (1 / 16) 0% (0 / 6) 8% (2 / 25)
Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/dev-server.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/dev-server.js

Statements: 6.67% (2 / 30)      Branches: 5.56% (1 / 18)      Functions: 0% (0 / 5)      Lines: 6.67% (2 / 30)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54          2                                                                                         2      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*globals window __webpack_hash__ */
Iif(module.hot) {
	var lastHash;
	var upToDate = function upToDate() {
		return lastHash.indexOf(__webpack_hash__) >= 0;
	};
	var check = function check() {
		module.hot.check(true).then(function(updatedModules) {
			if(!updatedModules) {
				console.warn("[HMR] Cannot find update. Need to do a full reload!");
				console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
				window.location.reload();
				return;
			}
 
			if(!upToDate()) {
				check();
			}
 
			require("./log-apply-result")(updatedModules, updatedModules);
 
			if(upToDate()) {
				console.log("[HMR] App is up to date.");
			}
 
		}).catch(function(err) {
			var status = module.hot.status();
			if(["abort", "fail"].indexOf(status) >= 0) {
				console.warn("[HMR] Cannot apply update. Need to do a full reload!");
				console.warn("[HMR] " + err.stack || err.message);
				window.location.reload();
			} else {
				console.warn("[HMR] Update failed: " + err.stack || err.message);
			}
		});
	};
	var hotEmitter = require("./emitter");
	hotEmitter.on("webpackHotUpdate", function(currentHash) {
		lastHash = currentHash;
		if(!upToDate() && module.hot.status() === "idle") {
			console.log("[HMR] Checking for updates on the server...");
			check();
		}
	});
	console.log("[HMR] Waiting for update signal from WDS...");
} else {
	throw new Error("[HMR] Hot Module Replacement is disabled.");
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/emitter.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/emitter.js

Statements: 100% (2 / 2)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (2 / 2)      Ignored: none     

1 2 3 41 1    
var EventEmitter = require("events");
module.exports = new EventEmitter();
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/only-dev-server.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/only-dev-server.js

Statements: 5.56% (2 / 36)      Branches: 5% (1 / 20)      Functions: 0% (0 / 9)      Lines: 5.56% (2 / 36)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71          2                                                                                                                           2      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*globals __webpack_hash__ */
Iif(module.hot) {
	var lastHash;
	var upToDate = function upToDate() {
		return lastHash.indexOf(__webpack_hash__) >= 0;
	};
	var check = function check() {
		module.hot.check().then(function(updatedModules) {
			if(!updatedModules) {
				console.warn("[HMR] Cannot find update. Need to do a full reload!");
				console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
				return;
			}
 
			return module.hot.apply({
				ignoreUnaccepted: true,
				ignoreDeclined: true,
				ignoreErrored: true,
				onUnaccepted: function(data) {
					console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
				},
				onDeclined: function(data) {
					console.warn("Ignored an update to declined module " + data.chain.join(" -> "));
				},
				onErrored: function(data) {
					console.warn("Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
				}
			}).then(function(renewedModules) {
				if(!upToDate()) {
					check();
				}
 
				require("./log-apply-result")(updatedModules, renewedModules);
 
				if(upToDate()) {
					console.log("[HMR] App is up to date.");
				}
			});
		}).catch(function(err) {
			var status = module.hot.status();
			if(["abort", "fail"].indexOf(status) >= 0) {
				console.warn("[HMR] Cannot check for update. Need to do a full reload!");
				console.warn("[HMR] " + err.stack || err.message);
			} else {
				console.warn("[HMR] Update check failed: " + err.stack || err.message);
			}
		});
	};
	var hotEmitter = require("./emitter");
	hotEmitter.on("webpackHotUpdate", function(currentHash) {
		lastHash = currentHash;
		if(!upToDate()) {
			var status = module.hot.status();
			if(status === "idle") {
				console.log("[HMR] Checking for updates on the server...");
				check();
			} else if(["abort", "fail"].indexOf(status) >= 0) {
				console.warn("[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
			}
		}
	});
	console.log("[HMR] Waiting for update signal from WDS...");
} else {
	throw new Error("[HMR] Hot Module Replacement is disabled.");
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/poll.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/poll.js

Statements: 10.53% (2 / 19)      Branches: 6.25% (1 / 16)      Functions: 0% (0 / 3)      Lines: 11.11% (2 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35          2                                                   2      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
Iif(module.hot) {
	var hotPollInterval = +(__resourceQuery.substr(1)) || (10 * 60 * 1000);
 
	var checkForUpdate = function checkForUpdate(fromUpdate) {
		if(module.hot.status() === "idle") {
			module.hot.check(true).then(function(updatedModules) {
				if(!updatedModules) {
					if(fromUpdate) console.log("[HMR] Update applied.");
					return;
				}
				require("./log-apply-result")(updatedModules, updatedModules);
				checkForUpdate(true);
			}).catch(function(err) {
				var status = module.hot.status();
				if(["abort", "fail"].indexOf(status) >= 0) {
					console.warn("[HMR] Cannot apply update.");
					console.warn("[HMR] " + err.stack || err.message);
					console.warn("[HMR] You need to restart the application!");
				} else {
					console.warn("[HMR] Update failed: " + err.stack || err.message);
				}
			});
		}
	};
	setInterval(checkForUpdate, hotPollInterval);
} else {
	throw new Error("[HMR] Hot Module Replacement is disabled.");
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/signal.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/hot/signal.js

Statements: 8% (2 / 25)      Branches: 6.25% (1 / 16)      Functions: 0% (0 / 6)      Lines: 8% (2 / 25)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52          2                                                                                     2      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
Iif(module.hot) {
	var checkForUpdate = function checkForUpdate(fromUpdate) {
		module.hot.check().then(function(updatedModules) {
			if(!updatedModules) {
				if(fromUpdate)
					console.log("[HMR] Update applied.");
				else
					console.warn("[HMR] Cannot find update.");
				return;
			}
 
			return module.hot.apply({
				ignoreUnaccepted: true,
				onUnaccepted: function(data) {
					console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
				},
			}).then(function(renewedModules) {
				require("./log-apply-result")(updatedModules, renewedModules);
 
				checkForUpdate(true);
			});
		}).catch(function(err) {
			var status = module.hot.status();
			if(["abort", "fail"].indexOf(status) >= 0) {
				console.warn("[HMR] Cannot apply update.");
				console.warn("[HMR] " + err.stack || err.message);
				console.warn("[HMR] You need to restart the application!");
			} else {
				console.warn("[HMR] Update failed: " + err.stack || err.message);
			}
		});
	};
 
	process.on(__resourceQuery.substr(1) || "SIGUSR2", function() {
		if(module.hot.status() !== "idle") {
			console.warn("[HMR] Got signal but currently in " + module.hot.status() + " state.");
			console.warn("[HMR] Need to be in idle state to start hot update.");
			return;
		}
 
		checkForUpdate();
	});
} else {
	throw new Error("[HMR] Hot Module Replacement is disabled.");
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/

Statements: 8.76% (677 / 7729)      Branches: 0.1% (4 / 3962)      Functions: 0.31% (3 / 975)      Lines: 9.28% (675 / 7272)      Ignored: 5 statements, 4 branches     

All files » node-npmtest-webpack/node_modules/webpack/lib/
File Statements Branches Functions Lines
APIPlugin.js 46.15% (6 / 13) 100% (0 / 0) 0% (0 / 1) 46.15% (6 / 13)
AmdMainTemplatePlugin.js 12% (3 / 25) 0% (0 / 8) 0% (0 / 2) 13.04% (3 / 23)
AsyncDependenciesBlock.js 6.06% (2 / 33) 0% (0 / 21) 0% (0 / 7) 7.14% (2 / 28)
AutomaticPrefetchPlugin.js 22.22% (4 / 18) 0% (0 / 4) 0% (0 / 1) 23.53% (4 / 17)
BannerPlugin.js 17.39% (4 / 23) 0% (0 / 14) 0% (0 / 3) 19.05% (4 / 21)
BasicEvaluatedExpression.js 1.15% (1 / 87) 0% (0 / 50) 0% (0 / 27) 1.32% (1 / 76)
CachePlugin.js 4.26% (2 / 47) 0% (0 / 38) 0% (0 / 4) 4.55% (2 / 44)
CaseSensitiveModulesWarning.js 28% (7 / 25) 66.67% (4 / 6) 0% (0 / 3) 22.73% (5 / 22)
Chunk.js 1.97% (4 / 203) 0% (0 / 98) 0% (0 / 35) 2.07% (4 / 193)
ChunkRenderError.js 20% (2 / 10) 100% (0 / 0) 0% (0 / 1) 20% (2 / 10)
ChunkTemplate.js 18.75% (3 / 16) 0% (0 / 2) 0% (0 / 4) 18.75% (3 / 16)
CompatibilityPlugin.js 16.13% (5 / 31) 0% (0 / 22) 0% (0 / 1) 17.86% (5 / 28)
Compilation.js 5.61% (42 / 749) 0% (0 / 321) 0% (0 / 67) 5.78% (42 / 727)
Compiler.js 10.09% (35 / 347) 0% (0 / 134) 0% (0 / 63) 11.29% (35 / 310)
ConstPlugin.js 13.16% (5 / 38) 0% (0 / 14) 0% (0 / 5) 13.89% (5 / 36)
ContextModule.js 5.08% (6 / 118) 0% (0 / 60) 0% (0 / 17) 5.17% (6 / 116)
ContextModuleFactory.js 11.34% (11 / 97) 0% (0 / 46) 0% (0 / 22) 13.41% (11 / 82)
ContextReplacementPlugin.js 5.33% (4 / 75) 0% (0 / 48) 0% (0 / 3) 5.56% (4 / 72)
DefinePlugin.js 12.35% (10 / 81) 0% (0 / 31) 0% (0 / 8) 14.08% (10 / 71)
DelegatedModule.js 14.63% (6 / 41) 0% (0 / 8) 0% (0 / 8) 14.63% (6 / 41)
DelegatedModuleFactoryPlugin.js 6.67% (2 / 30) 0% (0 / 20) 0% (0 / 2) 6.9% (2 / 29)
DelegatedPlugin.js 37.5% (3 / 8) 100% (0 / 0) 0% (0 / 2) 37.5% (3 / 8)
DependenciesBlock.js 14.71% (5 / 34) 0% (0 / 10) 0% (0 / 12) 15.63% (5 / 32)
DependenciesBlockVariable.js 12% (3 / 25) 0% (0 / 10) 0% (0 / 5) 13.64% (3 / 22)
Dependency.js 20% (3 / 15) 0% (0 / 4) 0% (0 / 9) 23.08% (3 / 13)
DllEntryPlugin.js 23.53% (4 / 17) 100% (0 / 0) 0% (0 / 2) 23.53% (4 / 17)
DllModule.js 13.64% (3 / 22) 0% (0 / 2) 0% (0 / 9) 13.64% (3 / 22)
DllModuleFactory.js 50% (3 / 6) 100% (0 / 0) 0% (0 / 2) 50% (3 / 6)
DllPlugin.js 29.41% (5 / 17) 0% (0 / 6) 0% (0 / 3) 29.41% (5 / 17)
DllReferencePlugin.js 13.79% (4 / 29) 0% (0 / 14) 0% (0 / 3) 14.29% (4 / 28)
DynamicEntryPlugin.js 21.21% (7 / 33) 0% (0 / 10) 0% (0 / 3) 22.58% (7 / 31)
EntryModuleNotFoundError.js 25% (2 / 8) 100% (0 / 0) 0% (0 / 1) 25% (2 / 8)
EntryOptionPlugin.js 29.41% (5 / 17) 0% (0 / 10) 0% (0 / 2) 31.25% (5 / 16)
Entrypoint.js 6.25% (1 / 16) 0% (0 / 4) 0% (0 / 4) 6.25% (1 / 16)
EnvironmentPlugin.js 10% (2 / 20) 0% (0 / 12) 0% (0 / 2) 10% (2 / 20)
ErrorHelpers.js 23.53% (4 / 17) 0% (0 / 8) 100% (0 / 0) 23.53% (4 / 17)
EvalDevToolModulePlugin.js 33.33% (2 / 6) 100% (0 / 0) 0% (0 / 2) 33.33% (2 / 6)
EvalDevToolModuleTemplatePlugin.js 23.08% (3 / 13) 0% (0 / 4) 0% (0 / 2) 23.08% (3 / 13)
EvalSourceMapDevToolModuleTemplatePlugin.js 6.52% (3 / 46) 0% (0 / 16) 0% (0 / 9) 6.52% (3 / 46)
EvalSourceMapDevToolPlugin.js 21.43% (3 / 14) 0% (0 / 6) 0% (0 / 2) 23.08% (3 / 13)
ExtendedAPIPlugin.js 25% (6 / 24) 100% (0 / 0) 0% (0 / 2) 26.09% (6 / 23)
ExternalModule.js 13.33% (6 / 45) 0% (0 / 21) 0% (0 / 15) 13.95% (6 / 43)
ExternalModuleFactoryPlugin.js 4.55% (3 / 66) 0% (0 / 44) 0% (0 / 8) 5.17% (3 / 58)
ExternalsPlugin.js 33.33% (2 / 6) 100% (0 / 0) 0% (0 / 2) 33.33% (2 / 6)
FlagDependencyExportsPlugin.js 7.81% (5 / 64) 0% (0 / 30) 0% (0 / 5) 8.47% (5 / 59)
FlagDependencyUsagePlugin.js 10.53% (6 / 57) 0% (0 / 32) 0% (0 / 6) 12.5% (6 / 48)
FlagInitialModulesAsUsedPlugin.js 12.5% (1 / 8) 0% (0 / 2) 0% (0 / 1) 12.5% (1 / 8)
FunctionModulePlugin.js 37.5% (3 / 8) 0% (0 / 2) 0% (0 / 2) 37.5% (3 / 8)
FunctionModuleTemplatePlugin.js 5.71% (2 / 35) 0% (0 / 23) 0% (0 / 4) 6.06% (2 / 33)
HashedModuleIdsPlugin.js 11.11% (2 / 18) 0% (0 / 6) 0% (0 / 2) 11.11% (2 / 18)
HotModuleReplacement.runtime.js 3.8% (13 / 342) 0% (0 / 183) 0% (0 / 36) 3.95% (13 / 329)
HotModuleReplacementPlugin.js 6.18% (11 / 178) 0% (0 / 71) 0% (0 / 33) 6.43% (11 / 171)
HotUpdateChunkTemplate.js 20% (2 / 10) 100% (0 / 0) 0% (0 / 3) 20% (2 / 10)
IgnorePlugin.js 5% (1 / 20) 0% (0 / 10) 0% (0 / 6) 5% (1 / 20)
JsonpChunkTemplatePlugin.js 11.11% (2 / 18) 0% (0 / 2) 0% (0 / 3) 11.76% (2 / 17)
JsonpExportMainTemplatePlugin.js 14.29% (2 / 14) 0% (0 / 4) 0% (0 / 2) 15.38% (2 / 13)
JsonpHotUpdateChunkTemplatePlugin.js 15.38% (2 / 13) 100% (0 / 0) 0% (0 / 3) 15.38% (2 / 13)
JsonpMainTemplate.runtime.js 10.81% (4 / 37) 0% (0 / 14) 0% (0 / 6) 11.43% (4 / 35)
JsonpMainTemplatePlugin.js 4.17% (2 / 48) 0% (0 / 14) 0% (0 / 9) 4.26% (2 / 47)
JsonpTemplatePlugin.js 50% (4 / 8) 100% (0 / 0) 0% (0 / 1) 50% (4 / 8)
LibManifestPlugin.js 13.64% (3 / 22) 0% (0 / 14) 0% (0 / 2) 14.29% (3 / 21)
LibraryTemplatePlugin.js 9.09% (4 / 44) 0% (0 / 27) 0% (0 / 4) 9.52% (4 / 42)
LoaderOptionsPlugin.js 10% (2 / 20) 0% (0 / 10) 0% (0 / 2) 11.76% (2 / 17)
LoaderTargetPlugin.js 20% (1 / 5) 100% (0 / 0) 0% (0 / 2) 25% (1 / 4)
MainTemplate.js 4.81% (5 / 104) 0% (0 / 18) 0% (0 / 10) 4.9% (5 / 102)
MemoryOutputFileSystem.js 100% (1 / 1) 100% (0 / 0) 100% (0 / 0) 100% (1 / 1)
Module.js 11.86% (14 / 118) 0% (0 / 40) 0% (0 / 20) 12.61% (14 / 111)
ModuleBuildError.js 14.29% (3 / 21) 0% (0 / 18) 0% (0 / 1) 14.29% (3 / 21)
ModuleDependencyError.js 30% (3 / 10) 100% (0 / 0) 0% (0 / 1) 30% (3 / 10)
ModuleDependencyWarning.js 30% (3 / 10) 100% (0 / 0) 0% (0 / 1) 30% (3 / 10)
ModuleError.js 30% (3 / 10) 0% (0 / 10) 0% (0 / 1) 30% (3 / 10)
ModuleFilenameHelpers.js 28.85% (30 / 104) 0% (0 / 42) 0% (0 / 10) 30.93% (30 / 97)
ModuleNotFoundError.js 16.67% (2 / 12) 100% (0 / 0) 0% (0 / 1) 16.67% (2 / 12)
ModuleParseError.js 12.5% (2 / 16) 0% (0 / 7) 0% (0 / 1) 12.5% (2 / 16)
ModuleReason.js 33.33% (1 / 3) 100% (0 / 0) 0% (0 / 1) 33.33% (1 / 3)
ModuleTemplate.js 22.22% (2 / 9) 100% (0 / 0) 0% (0 / 3) 22.22% (2 / 9)
ModuleWarning.js 30% (3 / 10) 0% (0 / 10) 0% (0 / 1) 30% (3 / 10)
MovedToPluginWarningPlugin.js 14.29% (1 / 7) 100% (0 / 0) 0% (0 / 2) 14.29% (1 / 7)
MultiCompiler.js 14.04% (16 / 114) 0% (0 / 42) 0% (0 / 30) 14.68% (16 / 109)
MultiEntryPlugin.js 21.05% (4 / 19) 100% (0 / 0) 0% (0 / 3) 21.05% (4 / 19)
MultiModule.js 8.11% (3 / 37) 0% (0 / 8) 0% (0 / 10) 8.57% (3 / 35)
MultiModuleFactory.js 50% (3 / 6) 100% (0 / 0) 0% (0 / 2) 50% (3 / 6)
MultiStats.js 6.25% (3 / 48) 0% (0 / 32) 0% (0 / 5) 7.5% (3 / 40)
MultiWatching.js 16.67% (2 / 12) 0% (0 / 2) 0% (0 / 3) 20% (2 / 10)
NamedChunksPlugin.js 12.5% (1 / 8) 0% (0 / 6) 0% (0 / 3) 12.5% (1 / 8)
NamedModulesPlugin.js 14.29% (1 / 7) 0% (0 / 8) 0% (0 / 2) 14.29% (1 / 7)
NewWatchingPlugin.js 33.33% (1 / 3) 100% (0 / 0) 0% (0 / 2) 33.33% (1 / 3)
NoEmitOnErrorsPlugin.js 12.5% (1 / 8) 0% (0 / 4) 0% (0 / 1) 12.5% (1 / 8)
NoErrorsPlugin.js 16.67% (2 / 12) 0% (0 / 6) 0% (0 / 1) 16.67% (2 / 12)
NodeStuffPlugin.js 10.94% (7 / 64) 0% (0 / 30) 0% (0 / 10) 11.67% (7 / 60)
NormalModule.js 8.3% (20 / 241) 0% (0 / 88) 0% (0 / 36) 8.77% (20 / 228)
NormalModuleFactory.js 5.63% (9 / 160) 0% (0 / 105) 0% (0 / 9) 6.25% (9 / 144)
NormalModuleReplacementPlugin.js 8.7% (2 / 23) 0% (0 / 12) 0% (0 / 2) 9.52% (2 / 21)
NullFactory.js 50% (1 / 2) 100% (0 / 0) 0% (0 / 1) 50% (1 / 2)
OptionsApply.js 100% (1 / 1) 100% (0 / 0) 0% (0 / 1) 100% (1 / 1)
OptionsDefaulter.js 7.32% (3 / 41) 0% (0 / 23) 0% (0 / 5) 8.11% (3 / 37)
Parser.js 1.09% (9 / 823) 0% (0 / 623) 0% (0 / 124) 1.17% (9 / 772)
ParserHelpers.js 29.55% (13 / 44) 0% (0 / 6) 0% (0 / 13) 30.95% (13 / 42)
PrefetchPlugin.js 18.18% (2 / 11) 0% (0 / 4) 0% (0 / 2) 18.18% (2 / 11)
ProgressPlugin.js 2.68% (3 / 112) 0% (0 / 43) 0% (0 / 10) 2.8% (3 / 107)
ProvidePlugin.js 12.9% (4 / 31) 0% (0 / 10) 0% (0 / 3) 13.33% (4 / 30)
RawModule.js 21.05% (4 / 19) 0% (0 / 6) 0% (0 / 7) 21.05% (4 / 19)
RecordIdsPlugin.js 2.73% (3 / 110) 0% (0 / 54) 0% (0 / 6) 3.57% (3 / 84)
RequestShortener.js 5.56% (2 / 36) 0% (0 / 28) 0% (0 / 2) 5.88% (2 / 34)
RequireJsStuffPlugin.js 28.57% (4 / 14) 0% (0 / 4) 0% (0 / 3) 28.57% (4 / 14)
RuleSet.js 2.9% (6 / 207) 0% (0 / 174) 0% (0 / 22) 2.96% (6 / 203)
SetVarMainTemplatePlugin.js 10.53% (2 / 19) 0% (0 / 4) 0% (0 / 2) 11.11% (2 / 18)
SingleEntryPlugin.js 14.29% (2 / 14) 100% (0 / 0) 0% (0 / 3) 14.29% (2 / 14)
SizeFormatHelpers.js 28.57% (2 / 7) 0% (0 / 2) 100% (0 / 0) 28.57% (2 / 7)
SourceMapDevToolModuleOptionsPlugin.js 10.53% (2 / 19) 0% (0 / 10) 0% (0 / 2) 11.76% (2 / 17)
SourceMapDevToolPlugin.js 6.96% (8 / 115) 0% (0 / 54) 0% (0 / 6) 7.27% (8 / 110)
Stats.js 1.12% (6 / 537) 0% (0 / 379) 0% (0 / 12) 1.19% (6 / 505)
Template.js 7.77% (8 / 103) 0% (0 / 58) 5.56% (1 / 18) 8.99% (8 / 89)
TemplatedPathPlugin.js 24.14% (14 / 58) 0% (0 / 51) 0% (0 / 5) 24.56% (14 / 57)
UmdMainTemplatePlugin.js 16.44% (12 / 73) 0% (0 / 60) 0% (0 / 13) 18.46% (12 / 65)
UnsupportedFeatureWarning.js 28.57% (2 / 7) 100% (0 / 0) 0% (0 / 1) 28.57% (2 / 7)
UseStrictPlugin.js 16.67% (2 / 12) 0% (0 / 6) 0% (0 / 1) 16.67% (2 / 12)
WarnCaseSensitiveModulesPlugin.js 15.38% (2 / 13) 0% (0 / 4) 0% (0 / 1) 15.38% (2 / 13)
WatchIgnorePlugin.js 4.76% (1 / 21) 0% (0 / 4) 0% (0 / 4) 5.88% (1 / 17)
WebpackError.js 50% (1 / 2) 0% (0 / 2) 0% (0 / 1) 50% (1 / 2)
WebpackOptionsApply.js 28.35% (36 / 127) 0% (0 / 73) 0% (0 / 2) 28.57% (36 / 126)
WebpackOptionsDefaulter.js 4.05% (3 / 74) 0% (0 / 14) 0% (0 / 1) 4.05% (3 / 74)
WebpackOptionsValidationError.js 4.84% (6 / 124) 0% (0 / 99) 0% (0 / 3) 5.26% (6 / 114)
compareLocations.js 3.13% (1 / 32) 0% (0 / 32) 0% (0 / 1) 4.17% (1 / 24)
formatLocation.js 7.41% (2 / 27) 0% (0 / 36) 0% (0 / 2) 7.41% (2 / 27)
removeAndDo.js 14.29% (1 / 7) 0% (0 / 2) 0% (0 / 1) 14.29% (1 / 7)
validateSchema.js 21.05% (8 / 38) 0% (0 / 12) 0% (0 / 4) 21.62% (8 / 37)
webpack.js 46.3% (25 / 54) 0% (0 / 25) 66.67% (2 / 3) 50% (25 / 50)
webpack.web.js 55.56% (10 / 18) 0% (0 / 2) 0% (0 / 1) 55.56% (10 / 18)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/APIPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/APIPlugin.js

Statements: 46.15% (6 / 13)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 46.15% (6 / 13)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47            1 1   1   1                 1                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConstDependency = require("./dependencies/ConstDependency");
const ParserHelpers = require("./ParserHelpers");
 
const NullFactory = require("./NullFactory");
 
const REPLACEMENTS = {
	__webpack_require__: "__webpack_require__", // eslint-disable-line camelcase
	__webpack_public_path__: "__webpack_require__.p", // eslint-disable-line camelcase
	__webpack_modules__: "__webpack_require__.m", // eslint-disable-line camelcase
	__webpack_chunk_load__: "__webpack_require__.e", // eslint-disable-line camelcase
	__non_webpack_require__: "require", // eslint-disable-line camelcase
	__webpack_nonce__: "__webpack_require__.nc", // eslint-disable-line camelcase
	"require.onError": "__webpack_require__.oe" // eslint-disable-line camelcase
};
const REPLACEMENT_TYPES = {
	__webpack_public_path__: "string", // eslint-disable-line camelcase
	__webpack_require__: "function", // eslint-disable-line camelcase
	__webpack_modules__: "object", // eslint-disable-line camelcase
	__webpack_chunk_load__: "function", // eslint-disable-line camelcase
	__webpack_nonce__: "string" // eslint-disable-line camelcase
};
 
class APIPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 
			params.normalModuleFactory.plugin("parser", parser => {
				Object.keys(REPLACEMENTS).forEach(key => {
					parser.plugin(`expression ${key}`, ParserHelpers.toConstantDependency(REPLACEMENTS[key]));
					parser.plugin(`evaluate typeof ${key}`, ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key]));
				});
			});
		});
	}
}
 
module.exports = APIPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/AmdMainTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/AmdMainTemplatePlugin.js

Statements: 12% (3 / 25)      Branches: 0% (0 / 8)      Functions: 0% (0 / 2)      Lines: 13.04% (3 / 23)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58              1 1                                                                                             1    
/*
 MIT License http://www.opensource.org/licenses/mit-license.php
 Author Tobias Koppers @sokra
 */
 
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
const Template = require("./Template");
 
class AmdMainTemplatePlugin {
	constructor(name) {
		this.name = name;
	}
 
	apply(compilation) {
		const mainTemplate = compilation.mainTemplate;
 
		compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
			const externals = chunk.modules.filter((m) => m.external);
			const externalsDepsArray = JSON.stringify(externals.map((m) =>
				typeof m.request === "object" ? m.request.amd : m.request
			));
			const externalsArguments = externals.map((m) =>
				Template.toIdentifier(`__WEBPACK_EXTERNAL_MODULE_${m.id}__`)
			).join(", ");
 
			if(this.name) {
				const name = mainTemplate.applyPluginsWaterfall("asset-path", this.name, {
					hash,
					chunk
				});
 
				return new ConcatSource(
					`define(${JSON.stringify(name)}, ${externalsDepsArray}, function(${externalsArguments}) { return `, source, "});"
				);
			} else if(externalsArguments) {
				return new ConcatSource(`define(${externalsDepsArray}, function(${externalsArguments}) { return `, source, "});");
			} else {
				return new ConcatSource("define(function() { return ", source, "});");
			}
		});
 
		mainTemplate.plugin("global-hash-paths", (paths) => {
			if(this.name) paths.push(this.name);
			return paths;
		});
 
		mainTemplate.plugin("hash", (hash) => {
			hash.update("exports amd");
			hash.update(this.name);
		});
	}
}
 
module.exports = AmdMainTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/AsyncDependenciesBlock.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/AsyncDependenciesBlock.js

Statements: 6.06% (2 / 33)      Branches: 0% (0 / 21)      Functions: 0% (0 / 7)      Lines: 7.14% (2 / 28)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55          1   1                                                                                              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const DependenciesBlock = require("./DependenciesBlock");
 
module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
	constructor(name, module, loc) {
		super();
		this.chunkName = name;
		this.chunks = null;
		this.module = module;
		this.loc = loc;
	}
	get chunk() {
		throw new Error("`chunk` was been renamed to `chunks` and is now an array");
	}
	set chunk(chunk) {
		throw new Error("`chunk` was been renamed to `chunks` and is now an array");
	}
	updateHash(hash) {
		hash.update(this.chunkName || "");
		hash.update(this.chunks && this.chunks.map((chunk) => {
			return chunk.id !== null ? chunk.id : "";
		}).join(",") || "");
		super.updateHash(hash);
	}
	disconnect() {
		this.chunks = null;
		super.disconnect();
	}
	unseal() {
		this.chunks = null;
		super.unseal();
	}
	sortItems() {
		super.sortItems();
		if(this.chunks) {
			this.chunks.sort((a, b) => {
				let i = 0;
				while(true) { // eslint-disable-line no-constant-condition
					if(!a.modules[i] && !b.modules[i]) return 0;
					if(!a.modules[i]) return -1;
					if(!b.modules[i]) return 1;
					if(a.modules[i].id > b.modules[i].id) return 1;
					if(a.modules[i].id < b.modules[i].id) return -1;
					i++;
				}
			});
		}
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/AutomaticPrefetchPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/AutomaticPrefetchPlugin.js

Statements: 22.22% (4 / 18)      Branches: 0% (0 / 4)      Functions: 0% (0 / 1)      Lines: 23.53% (4 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38            1 1 1                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const asyncLib = require("async");
const PrefetchDependency = require("./dependencies/PrefetchDependency");
const NormalModule = require("./NormalModule");
 
class AutomaticPrefetchPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(PrefetchDependency, normalModuleFactory);
		});
		let lastModules = null;
		compiler.plugin("after-compile", (compilation, callback) => {
			lastModules = compilation.modules
				.filter(m => m instanceof NormalModule)
				.map(m => ({
					context: m.context,
					request: m.request
				}));
			callback();
		});
		compiler.plugin("make", (compilation, callback) => {
			if(!lastModules) return callback();
			asyncLib.forEach(lastModules, (m, callback) => {
				compilation.prefetch(m.context || compiler.context, new PrefetchDependency(m.request), callback);
			}, callback);
		});
	}
}
module.exports = AutomaticPrefetchPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/BannerPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/BannerPlugin.js

Statements: 17.39% (4 / 23)      Branches: 0% (0 / 14)      Functions: 0% (0 / 3)      Lines: 19.05% (4 / 21)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53              1 1   1                                                                               1    
/*
 MIT License http://www.opensource.org/licenses/mit-license.php
 Author Tobias Koppers @sokra
 */
 
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
 
function wrapComment(str) {
	if(!str.includes("\n")) return `/*! ${str} */`;
	return `/*!\n * ${str.split("\n").join("\n * ")}\n */`;
}
 
class BannerPlugin {
	constructor(options) {
		if(arguments.length > 1)
			throw new Error("BannerPlugin only takes one argument (pass an options object)");
		if(typeof options === "string")
			options = {
				banner: options
			};
		this.options = options || {};
		this.banner = this.options.raw ? options.banner : wrapComment(options.banner);
	}
 
	apply(compiler) {
		const options = this.options;
		const banner = this.banner;
 
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
				chunks.forEach((chunk) => {
					if(options.entryOnly && !chunk.isInitial()) return;
 
					chunk.files
						.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options))
						.forEach((file) =>
							compilation.assets[file] = new ConcatSource(
								banner, "\n", compilation.assets[file]
							)
						);
				});
				callback();
			});
		});
	}
}
 
module.exports = BannerPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/BasicEvaluatedExpression.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/BasicEvaluatedExpression.js

Statements: 1.15% (1 / 87)      Branches: 0% (0 / 50)      Functions: 0% (0 / 27)      Lines: 1.32% (1 / 76)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183                                                                                                                                                                                                                                                                                                                                                                        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
 
"use strict";
 
class BasicEvaluatedExpression {
 
	constructor() {
		this.range = null;
	}
 
	isNull() {
		return !!this.null;
	}
 
	isString() {
		return Object.prototype.hasOwnProperty.call(this, "string");
	}
 
	isNumber() {
		return Object.prototype.hasOwnProperty.call(this, "number");
	}
 
	isBoolean() {
		return Object.prototype.hasOwnProperty.call(this, "bool");
	}
 
	isRegExp() {
		return Object.prototype.hasOwnProperty.call(this, "regExp");
	}
 
	isConditional() {
		return Object.prototype.hasOwnProperty.call(this, "options");
	}
 
	isArray() {
		return Object.prototype.hasOwnProperty.call(this, "items");
	}
 
	isConstArray() {
		return Object.prototype.hasOwnProperty.call(this, "array");
	}
 
	isIdentifier() {
		return Object.prototype.hasOwnProperty.call(this, "identifier");
	}
 
	isWrapped() {
		return Object.prototype.hasOwnProperty.call(this, "prefix") || Object.prototype.hasOwnProperty.call(this, "postfix");
	}
 
	isTemplateString() {
		return Object.prototype.hasOwnProperty.call(this, "quasis");
	}
 
	asBool() {
		if(this.isBoolean()) return this.bool;
		else if(this.isNull()) return false;
		else if(this.isString()) return !!this.string;
		else if(this.isNumber()) return !!this.number;
		else if(this.isRegExp()) return true;
		else if(this.isArray()) return true;
		else if(this.isConstArray()) return true;
		else if(this.isWrapped()) return this.prefix && this.prefix.asBool() || this.postfix && this.postfix.asBool() ? true : undefined;
		else if(this.isTemplateString()) {
			if(this.quasis.length === 1) return this.quasis[0].asBool();
			for(let i = 0; i < this.quasis.length; i++) {
				if(this.quasis[i].asBool()) return true;
			}
			// can't tell if string will be empty without executing
		}
		return undefined;
	}
 
	setString(str) {
		if(str === null)
			delete this.string;
		else
			this.string = str;
		return this;
	}
 
	setNull() {
		this.null = true;
		return this;
	}
 
	setNumber(num) {
		if(num === null)
			delete this.number;
		else
			this.number = num;
		return this;
	}
 
	setBoolean(bool) {
		if(bool === null)
			delete this.bool;
		else
			this.bool = bool;
		return this;
	}
 
	setRegExp(regExp) {
		if(regExp === null)
			delete this.regExp;
		else
			this.regExp = regExp;
		return this;
	}
 
	setIdentifier(identifier) {
		if(identifier === null)
			delete this.identifier;
		else
			this.identifier = identifier;
		return this;
	}
 
	setWrapped(prefix, postfix) {
		this.prefix = prefix;
		this.postfix = postfix;
		return this;
	}
 
	unsetWrapped() {
		delete this.prefix;
		delete this.postfix;
		return this;
	}
 
	setOptions(options) {
		if(options === null)
			delete this.options;
		else
			this.options = options;
		return this;
	}
 
	setItems(items) {
		if(items === null)
			delete this.items;
		else
			this.items = items;
		return this;
	}
 
	setArray(array) {
		if(array === null)
			delete this.array;
		else
			this.array = array;
		return this;
	}
 
	setTemplateString(quasis) {
		if(quasis === null)
			delete this.quasis;
		else
			this.quasis = quasis;
		return this;
	}
 
	addOptions(options) {
		if(!this.options) this.options = [];
		options.forEach(item => {
			this.options.push(item);
		}, this);
		return this;
	}
 
	setRange(range) {
		this.range = range;
		return this;
	}
 
}
 
module.exports = BasicEvaluatedExpression;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/CachePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/CachePlugin.js

Statements: 4.26% (2 / 47)      Branches: 0% (0 / 38)      Functions: 0% (0 / 4)      Lines: 4.55% (2 / 44)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81            1                                                                                                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const asyncLib = require("async");
 
class CachePlugin {
	constructor(cache) {
		this.cache = cache || {};
		this.FS_ACCURENCY = 2000;
	}
 
	apply(compiler) {
		if(Array.isArray(compiler.compilers)) {
			compiler.compilers.forEach((c, idx) => {
				c.apply(new CachePlugin(this.cache[idx] = this.cache[idx] || {}));
			});
		} else {
			compiler.plugin("compilation", compilation => {
				if(!compilation.notCacheable) {
					compilation.cache = this.cache;
				} else if(this.watching) {
					compilation.warnings.push(
						new Error(`CachePlugin - Cache cannot be used because of: ${compilation.notCacheable}`)
					);
				}
			});
			compiler.plugin("watch-run", (compiler, callback) => {
				this.watching = true;
				callback();
			});
			compiler.plugin("run", (compiler, callback) => {
				if(!compiler._lastCompilationFileDependencies) return callback();
				const fs = compiler.inputFileSystem;
				const fileTs = compiler.fileTimestamps = {};
				asyncLib.forEach(compiler._lastCompilationFileDependencies, (file, callback) => {
					fs.stat(file, (err, stat) => {
						if(err) {
							if(err.code === "ENOENT") return callback();
							return callback(err);
						}
 
						if(stat.mtime)
							this.applyMtime(+stat.mtime);
 
						fileTs[file] = +stat.mtime || Infinity;
						callback();
					});
				}, err => {
					if(err) return callback(err);
					Object.keys(fileTs).forEach(key => {
						fileTs[key] += this.FS_ACCURENCY;
					});
					callback();
				});
			});
			compiler.plugin("after-compile", function(compilation, callback) {
				compilation.compiler._lastCompilationFileDependencies = compilation.fileDependencies;
				compilation.compiler._lastCompilationContextDependencies = compilation.contextDependencies;
				callback();
			});
		}
	}
 
	/* istanbul ignore next */
	applyMtime(mtime) {
		if(this.FS_ACCURENCY > 1 && mtime % 2 !== 0)
			this.FS_ACCURENCY = 1;
		else if(this.FS_ACCURENCY > 10 && mtime % 20 !== 0)
			this.FS_ACCURENCY = 10;
		else if(this.FS_ACCURENCY > 100 && mtime % 200 !== 0)
			this.FS_ACCURENCY = 100;
		else if(this.FS_ACCURENCY > 1000 && mtime % 2000 !== 0)
			this.FS_ACCURENCY = 1000;
	}
}
module.exports = CachePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/CaseSensitiveModulesWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/CaseSensitiveModulesWarning.js

Statements: 28% (7 / 25)      Branches: 66.67% (4 / 6)      Functions: 0% (0 / 3)      Lines: 22.73% (5 / 22)      Ignored: 5 statements, 4 branches     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » CaseSensitiveModulesWarning.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51            1   1                                       1   1   1                                    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
 
module.exports = class CaseSensitiveModulesWarning extends WebpackError {
	constructor(modules) {
		super();
 
		this.name = "CaseSensitiveModulesWarning";
		const sortedModules = this._sort(modules);
		const modulesList = this._moduleMessages(sortedModules);
		this.message = "There are multiple modules with names that only differ in casing.\n" +
			"This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.\n" +
			`Use equal casing. Compare these module identifiers:\n${modulesList}`;
		this.origin = this.module = sortedModules[0];
 
		Error.captureStackTrace(this, this.constructor);
	}
 
	_sort(modules) {
		return modules.slice().sort((a, b) => {
			a = a.identifier();
			b = b.identifier();
			/* istanbul ignore next */
			if(a < b) return -1;
			/* istanbul ignore next */
			if(a > b) return 1;
			/* istanbul ignore next */
			return 0;
		});
	}
 
	_moduleMessages(modules) {
		return modules.map((m) => {
			let message = `* ${m.identifier()}`;
			const validReasons = m.reasons.filter((reason) => reason.module);
 
			if(validReasons.length > 0) {
				message += `\n    Used by ${validReasons.length} module(s), i. e.`;
				message += `\n    ${validReasons[0].module.identifier()}`;
			}
			return message;
		}).join("\n");
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Chunk.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Chunk.js

Statements: 1.97% (4 / 203)      Branches: 0% (0 / 98)      Functions: 0% (0 / 35)      Lines: 2.07% (4 / 193)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398            1 1   1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const compareLocations = require("./compareLocations");
let debugId = 1000;
 
const byId = (a, b) => {
	if(a.id < b.id) return -1;
	if(b.id < a.id) return 1;
	return 0;
};
 
class Chunk {
 
	constructor(name, module, loc) {
		this.id = null;
		this.ids = null;
		this.debugId = debugId++;
		this.name = name;
		this.modules = [];
		this.entrypoints = [];
		this.chunks = [];
		this.parents = [];
		this.blocks = [];
		this.origins = [];
		this.files = [];
		this.rendered = false;
		if(module) {
			this.origins.push({
				module,
				loc,
				name
			});
		}
	}
 
	get entry() {
		throw new Error("Chunk.entry was removed. Use hasRuntime()");
	}
 
	set entry(data) {
		throw new Error("Chunk.entry was removed. Use hasRuntime()");
	}
 
	get initial() {
		throw new Error("Chunk.initial was removed. Use isInitial()");
	}
 
	set initial(data) {
		throw new Error("Chunk.initial was removed. Use isInitial()");
	}
 
	hasRuntime() {
		if(this.entrypoints.length === 0) return false;
		return this.entrypoints[0].chunks[0] === this;
	}
 
	isInitial() {
		return this.entrypoints.length > 0;
	}
 
	hasEntryModule() {
		return !!this.entryModule;
	}
 
	addToCollection(collection, item) {
		if(item === this) {
			return false;
		}
 
		if(collection.indexOf(item) > -1) {
			return false;
		}
 
		collection.push(item);
		return true;
	}
 
	addChunk(chunk) {
		return this.addToCollection(this.chunks, chunk);
	}
 
	addParent(parentChunk) {
		return this.addToCollection(this.parents, parentChunk);
	}
 
	addModule(module) {
		return this.addToCollection(this.modules, module);
	}
 
	addBlock(block) {
		return this.addToCollection(this.blocks, block);
	}
 
	removeModule(module) {
		const idx = this.modules.indexOf(module);
		if(idx >= 0) {
			this.modules.splice(idx, 1);
			module.removeChunk(this);
			return true;
		}
		return false;
	}
 
	removeChunk(chunk) {
		const idx = this.chunks.indexOf(chunk);
		if(idx >= 0) {
			this.chunks.splice(idx, 1);
			chunk.removeParent(this);
			return true;
		}
		return false;
	}
 
	removeParent(chunk) {
		const idx = this.parents.indexOf(chunk);
		if(idx >= 0) {
			this.parents.splice(idx, 1);
			chunk.removeChunk(this);
			return true;
		}
		return false;
	}
 
	addOrigin(module, loc) {
		this.origins.push({
			module,
			loc,
			name: this.name
		});
	}
 
	remove(reason) {
		// cleanup modules
		this.modules.slice().forEach(module => {
			module.removeChunk(this);
		});
 
		// cleanup parents
		this.parents.forEach(parentChunk => {
			// remove this chunk from its parents
			const idx = parentChunk.chunks.indexOf(this);
			if(idx >= 0) {
				parentChunk.chunks.splice(idx, 1);
			}
 
			// cleanup "sub chunks"
			this.chunks.forEach(chunk => {
				/**
				 * remove this chunk as "intermediary" and connect
				 * it "sub chunks" and parents directly
				 */
				// add parent to each "sub chunk"
				chunk.addParent(parentChunk);
				// add "sub chunk" to parent
				parentChunk.addChunk(chunk);
			});
		});
 
		/**
		 * we need to iterate again over the chunks
		 * to remove this from the chunks parents.
		 * This can not be done in the above loop
		 * as it is not garuanteed that `this.parents` contains anything.
		 */
		this.chunks.forEach(chunk => {
			// remove this as parent of every "sub chunk"
			const idx = chunk.parents.indexOf(this);
			if(idx >= 0) {
				chunk.parents.splice(idx, 1);
			}
		});
 
		// cleanup blocks
		this.blocks.forEach(block => {
			const idx = block.chunks.indexOf(this);
			if(idx >= 0) {
				block.chunks.splice(idx, 1);
				if(block.chunks.length === 0) {
					block.chunks = null;
					block.chunkReason = reason;
				}
			}
		});
	}
 
	moveModule(module, otherChunk) {
		module.removeChunk(this);
		module.addChunk(otherChunk);
		otherChunk.addModule(module);
		module.rewriteChunkInReasons(this, [otherChunk]);
	}
 
	replaceChunk(oldChunk, newChunk) {
		const idx = this.chunks.indexOf(oldChunk);
		if(idx >= 0) {
			this.chunks.splice(idx, 1);
		}
		if(this !== newChunk && newChunk.addParent(this)) {
			this.addChunk(newChunk);
		}
	}
 
	replaceParentChunk(oldParentChunk, newParentChunk) {
		const idx = this.parents.indexOf(oldParentChunk);
		if(idx >= 0) {
			this.parents.splice(idx, 1);
		}
		if(this !== newParentChunk && newParentChunk.addChunk(this)) {
			this.addParent(newParentChunk);
		}
	}
 
	integrate(otherChunk, reason) {
		if(!this.canBeIntegrated(otherChunk)) {
			return false;
		}
 
		const otherChunkModules = otherChunk.modules.slice();
		otherChunkModules.forEach(module => otherChunk.moveModule(module, this));
		otherChunk.modules.length = 0;
 
		otherChunk.parents.forEach(parentChunk => parentChunk.replaceChunk(otherChunk, this));
		otherChunk.parents.length = 0;
 
		otherChunk.chunks.forEach(chunk => chunk.replaceParentChunk(otherChunk, this));
		otherChunk.chunks.length = 0;
 
		otherChunk.blocks.forEach(b => {
			b.chunks = b.chunks ? b.chunks.map(c => {
				return c === otherChunk ? this : c;
			}) : [this];
			b.chunkReason = reason;
			this.addBlock(b);
		});
		otherChunk.blocks.length = 0;
 
		otherChunk.origins.forEach(origin => {
			this.origins.push(origin);
		});
		this.origins.forEach(origin => {
			if(!origin.reasons) {
				origin.reasons = [reason];
			} else if(origin.reasons[0] !== reason) {
				origin.reasons.unshift(reason);
			}
		});
		this.chunks = this.chunks.filter(chunk => {
			return chunk !== otherChunk && chunk !== this;
		});
		this.parents = this.parents.filter(parentChunk => {
			return parentChunk !== otherChunk && parentChunk !== this;
		});
		return true;
	}
 
	split(newChunk) {
		this.blocks.forEach(block => {
			newChunk.blocks.push(block);
			block.chunks.push(newChunk);
		});
		this.chunks.forEach(chunk => {
			newChunk.chunks.push(chunk);
			chunk.parents.push(newChunk);
		});
		this.parents.forEach(parentChunk => {
			parentChunk.chunks.push(newChunk);
			newChunk.parents.push(parentChunk);
		});
		this.entrypoints.forEach(entrypoint => {
			entrypoint.insertChunk(newChunk, this);
		});
	}
 
	isEmpty() {
		return this.modules.length === 0;
	}
 
	updateHash(hash) {
		hash.update(`${this.id} `);
		hash.update(this.ids ? this.ids.join(",") : "");
		hash.update(`${this.name || ""} `);
		this.modules.forEach(m => m.updateHash(hash));
	}
 
	canBeIntegrated(otherChunk) {
		if(otherChunk.isInitial()) {
			return false;
		}
		if(this.isInitial()) {
			if(otherChunk.parents.length !== 1 || otherChunk.parents[0] !== this) {
				return false;
			}
		}
		return true;
	}
 
	addMultiplierAndOverhead(size, options) {
		const overhead = typeof options.chunkOverhead === "number" ? options.chunkOverhead : 10000;
		const multiplicator = this.isInitial() ? (options.entryChunkMultiplicator || 10) : 1;
 
		return size * multiplicator + overhead;
	}
 
	modulesSize() {
		let count = 0;
		for(let i = 0; i < this.modules.length; i++) {
			count += this.modules[i].size();
		}
		return count;
	}
 
	size(options) {
		return this.addMultiplierAndOverhead(this.modulesSize(), options);
	}
 
	integratedSize(otherChunk, options) {
		// Chunk if it's possible to integrate this chunk
		if(!this.canBeIntegrated(otherChunk)) {
			return false;
		}
 
		let integratedModulesSize = this.modulesSize();
		// only count modules that do not exist in this chunk!
		for(let i = 0; i < otherChunk.modules.length; i++) {
			const otherModule = otherChunk.modules[i];
			if(this.modules.indexOf(otherModule) === -1) {
				integratedModulesSize += otherModule.size();
			}
		}
 
		return this.addMultiplierAndOverhead(integratedModulesSize, options);
	}
 
	getChunkMaps(includeEntries, realHash) {
		const chunksProcessed = [];
		const chunkHashMap = {};
		const chunkNameMap = {};
		(function addChunk(chunk) {
			if(chunksProcessed.indexOf(chunk) >= 0) return;
			chunksProcessed.push(chunk);
			if(!chunk.hasRuntime() || includeEntries) {
				chunkHashMap[chunk.id] = realHash ? chunk.hash : chunk.renderedHash;
				if(chunk.name)
					chunkNameMap[chunk.id] = chunk.name;
			}
			chunk.chunks.forEach(addChunk);
		}(this));
		return {
			hash: chunkHashMap,
			name: chunkNameMap
		};
	}
 
	sortItems() {
		this.modules.sort(byId);
		this.origins.sort((a, b) => {
			const aIdent = a.module.identifier();
			const bIdent = b.module.identifier();
			if(aIdent < bIdent) return -1;
			if(aIdent > bIdent) return 1;
			return compareLocations(a.loc, b.loc);
		});
		this.origins.forEach(origin => {
			if(origin.reasons)
				origin.reasons.sort();
		});
		this.parents.sort(byId);
		this.chunks.sort(byId);
	}
 
	toString() {
		return `Chunk[${this.modules.join()}]`;
	}
 
	checkConstraints() {
		const chunk = this;
		chunk.chunks.forEach((child, idx) => {
			if(chunk.chunks.indexOf(child) !== idx)
				throw new Error(`checkConstraints: duplicate child in chunk ${chunk.debugId} ${child.debugId}`);
			if(child.parents.indexOf(chunk) < 0)
				throw new Error(`checkConstraints: child missing parent ${chunk.debugId} -> ${child.debugId}`);
		});
		chunk.parents.forEach((parentChunk, idx) => {
			if(chunk.parents.indexOf(parentChunk) !== idx)
				throw new Error(`checkConstraints: duplicate parent in chunk ${chunk.debugId} ${parentChunk.debugId}`);
			if(parentChunk.chunks.indexOf(chunk) < 0)
				throw new Error(`checkConstraints: parent missing child ${parentChunk.debugId} <- ${chunk.debugId}`);
		});
	}
}
 
module.exports = Chunk;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ChunkRenderError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ChunkRenderError.js

Statements: 20% (2 / 10)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 20% (2 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            1                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
 
class ChunkRenderError extends WebpackError {
	constructor(chunk, file, error) {
		super();
 
		this.name = "ChunkRenderError";
		this.error = error;
		this.message = error.message;
		this.details = error.stack;
		this.file = file;
		this.chunk = chunk;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = ChunkRenderError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ChunkTemplate.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ChunkTemplate.js

Statements: 18.75% (3 / 16)      Branches: 0% (0 / 2)      Functions: 0% (0 / 4)      Lines: 18.75% (3 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38            1 1   1                                                        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
const Template = require("./Template");
 
module.exports = class ChunkTemplate extends Template {
	constructor(outputOptions) {
		super(outputOptions);
	}
 
	render(chunk, moduleTemplate, dependencyTemplates) {
		const moduleSources = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates);
		const core = this.applyPluginsWaterfall("modules", moduleSources, chunk, moduleTemplate, dependencyTemplates);
		let source = this.applyPluginsWaterfall("render", core, chunk, moduleTemplate, dependencyTemplates);
		if(chunk.hasEntryModule()) {
			source = this.applyPluginsWaterfall("render-with-entry", source, chunk);
		}
		chunk.rendered = true;
		return new ConcatSource(source, ";");
	}
 
	updateHash(hash) {
		hash.update("ChunkTemplate");
		hash.update("2");
		this.applyPlugins("hash", hash);
	}
 
	updateHashForChunk(hash, chunk) {
		this.updateHash(hash);
		this.applyPlugins("hash-for-chunk", hash, chunk);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/CompatibilityPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/CompatibilityPlugin.js

Statements: 16.13% (5 / 31)      Branches: 0% (0 / 22)      Functions: 0% (0 / 1)      Lines: 17.86% (5 / 28)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59            1   1   1 1                                                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConstDependency = require("./dependencies/ConstDependency");
 
const NullFactory = require("./NullFactory");
 
const jsonLoaderPath = require.resolve("json-loader");
const matchJson = /\.json$/i;
 
class CompatibilityPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.browserify !== "undefined" && !parserOptions.browserify)
					return;
 
				parser.plugin("call require", (expr) => {
					// support for browserify style require delegator: "require(o, !0)"
					if(expr.arguments.length !== 2) return;
					const second = parser.evaluateExpression(expr.arguments[1]);
					if(!second.isBoolean()) return;
					if(second.asBool() !== true) return;
					const dep = new ConstDependency("require", expr.callee.range);
					dep.loc = expr.loc;
					if(parser.state.current.dependencies.length > 1) {
						const last = parser.state.current.dependencies[parser.state.current.dependencies.length - 1];
						if(last.critical && last.request === "." && last.userRequest === "." && last.recursive)
							parser.state.current.dependencies.pop();
					}
					parser.state.current.addDependency(dep);
					return true;
				});
			});
 
			params.normalModuleFactory.plugin("after-resolve", (data, done) => {
				// if this is a json file and there are no loaders active, we use the json-loader in order to avoid parse errors
				// @see https://github.com/webpack/webpack/issues/3363
				if(matchJson.test(data.request) && data.loaders.length === 0) {
					data.loaders.push({
						loader: jsonLoaderPath
					});
				}
				done(null, data);
			});
		});
	}
}
module.exports = CompatibilityPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Compilation.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Compilation.js

Statements: 5.61% (42 / 749)      Branches: 0% (0 / 321)      Functions: 0% (0 / 67)      Lines: 5.78% (42 / 727)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249            1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   1           1                 1                                                                                                                                                                                                 1                                                                       1                 1                                                                                                               1       1               1                                                                                                                                                                                                                                                                                                                                                                                             1                                                                                                               1                                                                                                                                                                                                                                                                                                                                                                                                                                                             1                         1           1     1       1                                                             1                 1           1 1       1                                                                                                                                                                                                                                                                                                                                                   1                                                                                                                                               1                                                                                                                                                                                                                                                                                                                                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
	*/
"use strict";
 
const asyncLib = require("async");
const crypto = require("crypto");
const Tapable = require("tapable");
const EntryModuleNotFoundError = require("./EntryModuleNotFoundError");
const ModuleNotFoundError = require("./ModuleNotFoundError");
const ModuleDependencyWarning = require("./ModuleDependencyWarning");
const ModuleDependencyError = require("./ModuleDependencyError");
const Module = require("./Module");
const Chunk = require("./Chunk");
const Entrypoint = require("./Entrypoint");
const Stats = require("./Stats");
const MainTemplate = require("./MainTemplate");
const ChunkTemplate = require("./ChunkTemplate");
const HotUpdateChunkTemplate = require("./HotUpdateChunkTemplate");
const ModuleTemplate = require("./ModuleTemplate");
const Dependency = require("./Dependency");
const ChunkRenderError = require("./ChunkRenderError");
const CachedSource = require("webpack-sources").CachedSource;
 
function byId(a, b) {
	if(a.id < b.id) return -1;
	if(a.id > b.id) return 1;
	return 0;
}
 
function iterationBlockVariable(variables, fn) {
	for(let indexVariable = 0; indexVariable < variables.length; indexVariable++) {
		let varDep = variables[indexVariable].dependencies;
		for(let indexVDep = 0; indexVDep < varDep.length; indexVDep++) {
			fn(varDep[indexVDep]);
		}
	}
}
 
function iterationOfArrayCallback(arr, fn) {
	for(let index = 0; index < arr.length; index++) {
		fn(arr[index]);
	}
}
 
class Compilation extends Tapable {
	constructor(compiler) {
		super();
		this.compiler = compiler;
		this.resolvers = compiler.resolvers;
		this.inputFileSystem = compiler.inputFileSystem;
 
		const options = this.options = compiler.options;
		this.outputOptions = options && options.output;
		this.bail = options && options.bail;
		this.profile = options && options.profile;
		this.performance = options && options.performance;
 
		this.mainTemplate = new MainTemplate(this.outputOptions);
		this.chunkTemplate = new ChunkTemplate(this.outputOptions);
		this.hotUpdateChunkTemplate = new HotUpdateChunkTemplate(this.outputOptions);
		this.moduleTemplate = new ModuleTemplate(this.outputOptions);
 
		this.entries = [];
		this.preparedChunks = [];
		this.entrypoints = {};
		this.chunks = [];
		this.namedChunks = {};
		this.modules = [];
		this._modules = {};
		this.cache = null;
		this.records = null;
		this.nextFreeModuleIndex = undefined;
		this.nextFreeModuleIndex2 = undefined;
		this.additionalChunkAssets = [];
		this.assets = {};
		this.errors = [];
		this.warnings = [];
		this.children = [];
		this.dependencyFactories = new Map();
		this.dependencyTemplates = new Map();
	}
 
	templatesPlugin(name, fn) {
		this.mainTemplate.plugin(name, fn);
		this.chunkTemplate.plugin(name, fn);
	}
 
	addModule(module, cacheGroup) {
		const identifier = module.identifier();
		if(this._modules[identifier]) {
			return false;
		}
		const cacheName = (cacheGroup || "m") + identifier;
		if(this.cache && this.cache[cacheName]) {
			const cacheModule = this.cache[cacheName];
 
			let rebuild = true;
			if(!cacheModule.error && cacheModule.cacheable && this.fileTimestamps && this.contextTimestamps) {
				rebuild = cacheModule.needRebuild(this.fileTimestamps, this.contextTimestamps);
			}
 
			if(!rebuild) {
				cacheModule.disconnect();
				this._modules[identifier] = cacheModule;
				this.modules.push(cacheModule);
				cacheModule.errors.forEach(err => this.errors.push(err), this);
				cacheModule.warnings.forEach(err => this.warnings.push(err), this);
				return cacheModule;
			} else {
				module.lastId = cacheModule.id;
			}
		}
		module.unbuild();
		this._modules[identifier] = module;
		if(this.cache) {
			this.cache[cacheName] = module;
		}
		this.modules.push(module);
		return true;
	}
 
	getModule(module) {
		const identifier = module.identifier();
		return this._modules[identifier];
	}
 
	findModule(identifier) {
		return this._modules[identifier];
	}
 
	buildModule(module, optional, origin, dependencies, thisCallback) {
		this.applyPlugins1("build-module", module);
		if(module.building) return module.building.push(thisCallback);
		const building = module.building = [thisCallback];
 
		function callback(err) {
			module.building = undefined;
			building.forEach(cb => cb(err));
		}
		module.build(this.options, this, this.resolvers.normal, this.inputFileSystem, (error) => {
			const errors = module.errors;
			for(let indexError = 0; indexError < errors.length; indexError++) {
				const err = errors[indexError];
				err.origin = origin;
				err.dependencies = dependencies;
				if(optional)
					this.warnings.push(err);
				else
					this.errors.push(err);
			}
 
			const warnings = module.warnings;
			for(let indexWarning = 0; indexWarning < warnings.length; indexWarning++) {
				const war = warnings[indexWarning];
				war.origin = origin;
				war.dependencies = dependencies;
				this.warnings.push(war);
			}
			module.dependencies.sort(Dependency.compare);
			if(error) {
				this.applyPlugins2("failed-module", module, error);
				return callback(error);
			}
			this.applyPlugins1("succeed-module", module);
			return callback();
		});
	}
 
	processModuleDependencies(module, callback) {
		const dependencies = [];
 
		function addDependency(dep) {
			for(let i = 0; i < dependencies.length; i++) {
				if(dep.isEqualResource(dependencies[i][0])) {
					return dependencies[i].push(dep);
				}
			}
			dependencies.push([dep]);
		}
 
		function addDependenciesBlock(block) {
			if(block.dependencies) {
				iterationOfArrayCallback(block.dependencies, addDependency);
			}
			if(block.blocks) {
				iterationOfArrayCallback(block.blocks, addDependenciesBlock);
			}
			if(block.variables) {
				iterationBlockVariable(block.variables, addDependency);
			}
		}
		addDependenciesBlock(module);
		this.addModuleDependencies(module, dependencies, this.bail, null, true, callback);
	}
 
	addModuleDependencies(module, dependencies, bail, cacheGroup, recursive, callback) {
		let _this = this;
		const start = _this.profile && +new Date();
 
		const factories = [];
		for(let i = 0; i < dependencies.length; i++) {
			const factory = _this.dependencyFactories.get(dependencies[i][0].constructor);
			if(!factory) {
				return callback(new Error(`No module factory available for dependency type: ${dependencies[i][0].constructor.name}`));
			}
			factories[i] = [factory, dependencies[i]];
		}
		asyncLib.forEach(factories, function iteratorFactory(item, callback) {
			const dependencies = item[1];
 
			const errorAndCallback = function errorAndCallback(err) {
				err.origin = module;
				_this.errors.push(err);
				if(bail) {
					callback(err);
				} else {
					callback();
				}
			};
			const warningAndCallback = function warningAndCallback(err) {
				err.origin = module;
				_this.warnings.push(err);
				callback();
			};
 
			const factory = item[0];
			factory.create({
				contextInfo: {
					issuer: module.nameForCondition && module.nameForCondition(),
					compiler: _this.compiler.name
				},
				context: module.context,
				dependencies: dependencies
			}, function factoryCallback(err, dependentModule) {
				let afterFactory;
 
				function isOptional() {
					return dependencies.filter(d => !d.optional).length === 0;
				}
 
				function errorOrWarningAndCallback(err) {
					if(isOptional()) {
						return warningAndCallback(err);
					} else {
						return errorAndCallback(err);
					}
				}
 
				function iterationDependencies(depend) {
					for(let index = 0; index < depend.length; index++) {
						const dep = depend[index];
						dep.module = dependentModule;
						dependentModule.addReason(module, dep);
					}
				}
 
				if(err) {
					return errorOrWarningAndCallback(new ModuleNotFoundError(module, err, dependencies));
				}
				if(!dependentModule) {
					return process.nextTick(callback);
				}
				if(_this.profile) {
					if(!dependentModule.profile) {
						dependentModule.profile = {};
					}
					afterFactory = +new Date();
					dependentModule.profile.factory = afterFactory - start;
				}
 
				dependentModule.issuer = module;
				const newModule = _this.addModule(dependentModule, cacheGroup);
 
				if(!newModule) { // from cache
					dependentModule = _this.getModule(dependentModule);
 
					if(dependentModule.optional) {
						dependentModule.optional = isOptional();
					}
 
					iterationDependencies(dependencies);
 
					if(_this.profile) {
						if(!module.profile) {
							module.profile = {};
						}
						const time = +new Date() - start;
						if(!module.profile.dependencies || time > module.profile.dependencies) {
							module.profile.dependencies = time;
						}
					}
 
					return process.nextTick(callback);
				}
 
				if(newModule instanceof Module) {
					if(_this.profile) {
						newModule.profile = dependentModule.profile;
					}
 
					newModule.optional = isOptional();
					newModule.issuer = dependentModule.issuer;
					dependentModule = newModule;
 
					iterationDependencies(dependencies);
 
					if(_this.profile) {
						const afterBuilding = +new Date();
						module.profile.building = afterBuilding - afterFactory;
					}
 
					if(recursive) {
						return process.nextTick(_this.processModuleDependencies.bind(_this, dependentModule, callback));
					} else {
						return process.nextTick(callback);
					}
				}
 
				dependentModule.optional = isOptional();
 
				iterationDependencies(dependencies);
 
				_this.buildModule(dependentModule, isOptional(), module, dependencies, err => {
					if(err) {
						return errorOrWarningAndCallback(err);
					}
 
					if(_this.profile) {
						const afterBuilding = +new Date();
						dependentModule.profile.building = afterBuilding - afterFactory;
					}
 
					if(recursive) {
						_this.processModuleDependencies(dependentModule, callback);
					} else {
						return callback();
					}
				});
 
			});
		}, function finalCallbackAddModuleDependencies(err) {
			// In V8, the Error objects keep a reference to the functions on the stack. These warnings &
			// errors are created inside closures that keep a reference to the Compilation, so errors are
			// leaking the Compilation object. Setting _this to null workarounds the following issue in V8.
			// https://bugs.chromium.org/p/chromium/issues/detail?id=612191
			_this = null;
 
			if(err) {
				return callback(err);
			}
 
			return process.nextTick(callback);
		});
	}
 
	_addModuleChain(context, dependency, onModule, callback) {
		const start = this.profile && +new Date();
 
		const errorAndCallback = this.bail ? function errorAndCallback(err) {
			callback(err);
		} : function errorAndCallback(err) {
			err.dependencies = [dependency];
			this.errors.push(err);
			callback();
		}.bind(this);
 
		if(typeof dependency !== "object" || dependency === null || !dependency.constructor) {
			throw new Error("Parameter 'dependency' must be a Dependency");
		}
 
		const moduleFactory = this.dependencyFactories.get(dependency.constructor);
		if(!moduleFactory) {
			throw new Error(`No dependency factory available for this dependency type: ${dependency.constructor.name}`);
		}
 
		moduleFactory.create({
			contextInfo: {
				issuer: "",
				compiler: this.compiler.name
			},
			context: context,
			dependencies: [dependency]
		}, (err, module) => {
			if(err) {
				return errorAndCallback(new EntryModuleNotFoundError(err));
			}
 
			let afterFactory;
 
			if(this.profile) {
				if(!module.profile) {
					module.profile = {};
				}
				afterFactory = +new Date();
				module.profile.factory = afterFactory - start;
			}
 
			const result = this.addModule(module);
			if(!result) {
				module = this.getModule(module);
 
				onModule(module);
 
				if(this.profile) {
					const afterBuilding = +new Date();
					module.profile.building = afterBuilding - afterFactory;
				}
 
				return callback(null, module);
			}
 
			if(result instanceof Module) {
				if(this.profile) {
					result.profile = module.profile;
				}
 
				module = result;
 
				onModule(module);
 
				moduleReady.call(this);
				return;
			}
 
			onModule(module);
 
			this.buildModule(module, false, null, null, (err) => {
				if(err) {
					return errorAndCallback(err);
				}
 
				if(this.profile) {
					const afterBuilding = +new Date();
					module.profile.building = afterBuilding - afterFactory;
				}
 
				moduleReady.call(this);
			});
 
			function moduleReady() {
				this.processModuleDependencies(module, err => {
					if(err) {
						return callback(err);
					}
 
					return callback(null, module);
				});
			}
		});
	}
 
	addEntry(context, entry, name, callback) {
		const slot = {
			name: name,
			module: null
		};
		this.preparedChunks.push(slot);
		this._addModuleChain(context, entry, (module) => {
 
			entry.module = module;
			this.entries.push(module);
			module.issuer = null;
 
		}, (err, module) => {
			if(err) {
				return callback(err);
			}
 
			if(module) {
				slot.module = module;
			} else {
				const idx = this.preparedChunks.indexOf(slot);
				this.preparedChunks.splice(idx, 1);
			}
			return callback(null, module);
		});
	}
 
	prefetch(context, dependency, callback) {
		this._addModuleChain(context, dependency, module => {
 
			module.prefetched = true;
			module.issuer = null;
 
		}, callback);
	}
 
	rebuildModule(module, thisCallback) {
		if(module.variables.length || module.blocks.length)
			throw new Error("Cannot rebuild a complex module with variables or blocks");
		if(module.rebuilding) {
			return module.rebuilding.push(thisCallback);
		}
		const rebuilding = module.rebuilding = [thisCallback];
 
		function callback(err) {
			module.rebuilding = undefined;
			rebuilding.forEach(cb => cb(err));
		}
		const deps = module.dependencies.slice();
		this.buildModule(module, false, module, null, (err) => {
			if(err) return callback(err);
 
			this.processModuleDependencies(module, (err) => {
				if(err) return callback(err);
				deps.forEach(d => {
					if(d.module && d.module.removeReason(module, d)) {
						module.chunks.forEach(chunk => {
							if(!d.module.hasReasonForChunk(chunk)) {
								if(d.module.removeChunk(chunk)) {
									this.removeChunkFromDependencies(d.module, chunk);
								}
							}
						});
					}
				});
				callback();
			});
 
		});
	}
 
	finish() {
		const modules = this.modules;
		this.applyPlugins1("finish-modules", modules);
 
		for(let index = 0; index < modules.length; index++) {
			const module = modules[index];
			this.reportDependencyErrorsAndWarnings(module, [module]);
		}
	}
 
	unseal() {
		this.applyPlugins0("unseal");
		this.chunks.length = 0;
		this.namedChunks = {};
		this.additionalChunkAssets.length = 0;
		this.assets = {};
		this.modules.forEach(module => module.unseal());
	}
 
	seal(callback) {
		const self = this;
		self.applyPlugins0("seal");
		self.nextFreeModuleIndex = 0;
		self.nextFreeModuleIndex2 = 0;
		self.preparedChunks.forEach(preparedChunk => {
			const module = preparedChunk.module;
			const chunk = self.addChunk(preparedChunk.name, module);
			const entrypoint = self.entrypoints[chunk.name] = new Entrypoint(chunk.name);
			entrypoint.unshiftChunk(chunk);
 
			chunk.addModule(module);
			module.addChunk(chunk);
			chunk.entryModule = module;
			self.assignIndex(module);
			self.assignDepth(module);
			self.processDependenciesBlockForChunk(module, chunk);
		});
		self.sortModules(self.modules);
		self.applyPlugins0("optimize");
 
		while(self.applyPluginsBailResult1("optimize-modules-basic", self.modules) ||
			self.applyPluginsBailResult1("optimize-modules", self.modules) ||
			self.applyPluginsBailResult1("optimize-modules-advanced", self.modules)); // eslint-disable-line no-extra-semi
		self.applyPlugins1("after-optimize-modules", self.modules);
 
		while(self.applyPluginsBailResult1("optimize-chunks-basic", self.chunks) ||
			self.applyPluginsBailResult1("optimize-chunks", self.chunks) ||
			self.applyPluginsBailResult1("optimize-chunks-advanced", self.chunks)); // eslint-disable-line no-extra-semi
		self.applyPlugins1("after-optimize-chunks", self.chunks);
 
		self.applyPluginsAsyncSeries("optimize-tree", self.chunks, self.modules, function sealPart2(err) {
			if(err) {
				return callback(err);
			}
 
			self.applyPlugins2("after-optimize-tree", self.chunks, self.modules);
 
			const shouldRecord = self.applyPluginsBailResult("should-record") !== false;
 
			self.applyPlugins2("revive-modules", self.modules, self.records);
			self.applyPlugins1("optimize-module-order", self.modules);
			self.applyPlugins1("advanced-optimize-module-order", self.modules);
			self.applyPlugins1("before-module-ids", self.modules);
			self.applyPlugins1("module-ids", self.modules);
			self.applyModuleIds();
			self.applyPlugins1("optimize-module-ids", self.modules);
			self.applyPlugins1("after-optimize-module-ids", self.modules);
 
			self.sortItemsWithModuleIds();
 
			self.applyPlugins2("revive-chunks", self.chunks, self.records);
			self.applyPlugins1("optimize-chunk-order", self.chunks);
			self.applyPlugins1("before-chunk-ids", self.chunks);
			self.applyChunkIds();
			self.applyPlugins1("optimize-chunk-ids", self.chunks);
			self.applyPlugins1("after-optimize-chunk-ids", self.chunks);
 
			self.sortItemsWithChunkIds();
 
			if(shouldRecord)
				self.applyPlugins2("record-modules", self.modules, self.records);
			if(shouldRecord)
				self.applyPlugins2("record-chunks", self.chunks, self.records);
 
			self.applyPlugins0("before-hash");
			self.createHash();
			self.applyPlugins0("after-hash");
 
			if(shouldRecord)
				self.applyPlugins1("record-hash", self.records);
 
			self.applyPlugins0("before-module-assets");
			self.createModuleAssets();
			if(self.applyPluginsBailResult("should-generate-chunk-assets") !== false) {
				self.applyPlugins0("before-chunk-assets");
				self.createChunkAssets();
			}
			self.applyPlugins1("additional-chunk-assets", self.chunks);
			self.summarizeDependencies();
			if(shouldRecord)
				self.applyPlugins2("record", self, self.records);
 
			self.applyPluginsAsync("additional-assets", err => {
				if(err) {
					return callback(err);
				}
				self.applyPluginsAsync("optimize-chunk-assets", self.chunks, err => {
					if(err) {
						return callback(err);
					}
					self.applyPlugins1("after-optimize-chunk-assets", self.chunks);
					self.applyPluginsAsync("optimize-assets", self.assets, err => {
						if(err) {
							return callback(err);
						}
						self.applyPlugins1("after-optimize-assets", self.assets);
						if(self.applyPluginsBailResult("need-additional-seal")) {
							self.unseal();
							return self.seal(callback);
						}
						return self.applyPluginsAsync("after-seal", callback);
					});
				});
			});
		});
	}
 
	sortModules(modules) {
		modules.sort((a, b) => {
			if(a.index < b.index) return -1;
			if(a.index > b.index) return 1;
			return 0;
		});
	}
 
	reportDependencyErrorsAndWarnings(module, blocks) {
		for(let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
			const block = blocks[indexBlock];
			const dependencies = block.dependencies;
 
			for(let indexDep = 0; indexDep < dependencies.length; indexDep++) {
				const d = dependencies[indexDep];
 
				const warnings = d.getWarnings();
				if(warnings) {
					for(let indexWar = 0; indexWar < warnings.length; indexWar++) {
						const w = warnings[indexWar];
 
						const warning = new ModuleDependencyWarning(module, w, d.loc);
						this.warnings.push(warning);
					}
				}
				const errors = d.getErrors();
				if(errors) {
					for(let indexErr = 0; indexErr < errors.length; indexErr++) {
						const e = errors[indexErr];
 
						const error = new ModuleDependencyError(module, e, d.loc);
						this.errors.push(error);
					}
				}
			}
 
			this.reportDependencyErrorsAndWarnings(module, block.blocks);
		}
	}
 
	addChunk(name, module, loc) {
		if(name) {
			if(Object.prototype.hasOwnProperty.call(this.namedChunks, name)) {
				const chunk = this.namedChunks[name];
				if(module) {
					chunk.addOrigin(module, loc);
				}
				return chunk;
			}
		}
		const chunk = new Chunk(name, module, loc);
		this.chunks.push(chunk);
		if(name) {
			this.namedChunks[name] = chunk;
		}
		return chunk;
	}
 
	assignIndex(module) {
		const _this = this;
 
		const queue = [() => {
			assignIndexToModule(module);
		}];
 
		const iteratorAllDependencies = d => {
			queue.push(() => assignIndexToDependency(d));
		};
 
		function assignIndexToModule(module) {
			// enter module
			if(typeof module.index !== "number") {
				module.index = _this.nextFreeModuleIndex++;
 
				// leave module
				queue.push(() => module.index2 = _this.nextFreeModuleIndex2++);
 
				// enter it as block
				assignIndexToDependencyBlock(module);
			}
		}
 
		function assignIndexToDependency(dependency) {
			if(dependency.module) {
				queue.push(() => assignIndexToModule(dependency.module));
			}
		}
 
		function assignIndexToDependencyBlock(block) {
			let allDependencies = [];
 
			function iteratorDependency(d) {
				allDependencies.push(d);
			}
 
			function iteratorBlock(b) {
				queue.push(() => assignIndexToDependencyBlock(b));
			}
 
			if(block.variables) {
				iterationBlockVariable(block.variables, iteratorDependency);
			}
 
			if(block.dependencies) {
				iterationOfArrayCallback(block.dependencies, iteratorDependency);
			}
			if(block.blocks) {
				const blocks = block.blocks;
				let indexBlock = blocks.length;
				while(indexBlock--) {
					iteratorBlock(blocks[indexBlock]);
				}
			}
 
			let indexAll = allDependencies.length;
			while(indexAll--) {
				iteratorAllDependencies(allDependencies[indexAll]);
			}
		}
 
		while(queue.length) {
			queue.pop()();
		}
	}
 
	assignDepth(module) {
		function assignDepthToModule(module, depth) {
			// enter module
			if(typeof module.depth === "number" && module.depth <= depth) return;
			module.depth = depth;
 
			// enter it as block
			assignDepthToDependencyBlock(module, depth + 1);
		}
 
		function assignDepthToDependency(dependency, depth) {
			if(dependency.module) {
				queue.push(() => assignDepthToModule(dependency.module, depth));
			}
		}
 
		function assignDepthToDependencyBlock(block, depth) {
			function iteratorDependency(d) {
				assignDepthToDependency(d, depth);
			}
 
			function iteratorBlock(b) {
				assignDepthToDependencyBlock(b, depth);
			}
 
			if(block.variables) {
				iterationBlockVariable(block.variables, iteratorDependency);
			}
 
			if(block.dependencies) {
				iterationOfArrayCallback(block.dependencies, iteratorDependency);
			}
 
			if(block.blocks) {
				iterationOfArrayCallback(block.blocks, iteratorBlock);
			}
		}
 
		const queue = [() => {
			assignDepthToModule(module, 0);
		}];
		while(queue.length) {
			queue.pop()();
		}
	}
 
	processDependenciesBlockForChunk(block, chunk) {
		const iteratorBlock = b => {
			let c;
			if(!b.chunks) {
				c = this.addChunk(b.chunkName, b.module, b.loc);
				b.chunks = [c];
				c.addBlock(b);
			} else {
				c = b.chunks[0];
			}
			chunk.addChunk(c);
			c.addParent(chunk);
			queue.push([b, c]);
		};
 
		const iteratorDependency = d => {
			if(!d.module) {
				return;
			}
			if(d.weak) {
				return;
			}
			if(chunk.addModule(d.module)) {
				d.module.addChunk(chunk);
				queue.push([d.module, chunk]);
			}
		};
 
		const queue = [
			[block, chunk]
		];
 
		while(queue.length) {
			const queueItem = queue.pop();
			block = queueItem[0];
			chunk = queueItem[1];
 
			if(block.variables) {
				iterationBlockVariable(block.variables, iteratorDependency);
			}
 
			if(block.dependencies) {
				iterationOfArrayCallback(block.dependencies, iteratorDependency);
			}
 
			if(block.blocks) {
				iterationOfArrayCallback(block.blocks, iteratorBlock);
			}
		}
	}
 
	removeChunkFromDependencies(block, chunk) {
		const iteratorDependency = d => {
			if(!d.module) {
				return;
			}
			if(!d.module.hasReasonForChunk(chunk)) {
				if(d.module.removeChunk(chunk)) {
					this.removeChunkFromDependencies(d.module, chunk);
				}
			}
		};
 
		const blocks = block.blocks;
		for(let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
			const chunks = blocks[indexBlock].chunks;
			for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
				const blockChunk = chunks[indexChunk];
				chunk.removeChunk(blockChunk);
				blockChunk.removeParent(chunk);
				this.removeChunkFromDependencies(chunks, blockChunk);
			}
		}
 
		if(block.dependencies) {
			iterationOfArrayCallback(block.dependencies, iteratorDependency);
		}
 
		if(block.variables) {
			iterationBlockVariable(block.variables, iteratorDependency);
		}
	}
 
	applyModuleIds() {
		let unusedIds = [];
		let nextFreeModuleId = 0;
		let usedIds = [];
		// TODO consider Map when performance has improved https://gist.github.com/sokra/234c077e1299b7369461f1708519c392
		const usedIdMap = Object.create(null);
		if(this.usedModuleIds) {
			Object.keys(this.usedModuleIds).forEach(key => {
				const id = this.usedModuleIds[key];
				if(!usedIdMap[id]) {
					usedIds.push(id);
					usedIdMap[id] = true;
				}
			});
		}
 
		const modules1 = this.modules;
		for(let indexModule1 = 0; indexModule1 < modules1.length; indexModule1++) {
			const module1 = modules1[indexModule1];
			if(module1.id && !usedIdMap[module1.id]) {
				usedIds.push(module1.id);
				usedIdMap[module1.id] = true;
			}
		}
 
		if(usedIds.length > 0) {
			let usedIdMax = -1;
			for(let index = 0; index < usedIds.length; index++) {
				const usedIdKey = usedIds[index];
 
				if(typeof usedIdKey !== "number") {
					continue;
				}
 
				usedIdMax = Math.max(usedIdMax, usedIdKey);
			}
 
			let lengthFreeModules = nextFreeModuleId = usedIdMax + 1;
 
			while(lengthFreeModules--) {
				if(!usedIdMap[lengthFreeModules]) {
					unusedIds.push(lengthFreeModules);
				}
			}
		}
 
		const modules2 = this.modules;
		for(let indexModule2 = 0; indexModule2 < modules2.length; indexModule2++) {
			const module2 = modules2[indexModule2];
			if(module2.id === null) {
				if(unusedIds.length > 0)
					module2.id = unusedIds.pop();
				else
					module2.id = nextFreeModuleId++;
			}
		}
	}
 
	applyChunkIds() {
		const unusedIds = [];
		let nextFreeChunkId = 0;
 
		function getNextFreeChunkId(usedChunkIds) {
			const keyChunks = Object.keys(usedChunkIds);
			let result = -1;
 
			for(let index = 0; index < keyChunks.length; index++) {
				const usedIdKey = keyChunks[index];
				const usedIdValue = usedChunkIds[usedIdKey];
 
				if(typeof usedIdValue !== "number") {
					continue;
				}
 
				result = Math.max(result, usedIdValue);
			}
 
			return result;
		}
 
		if(this.usedChunkIds) {
			nextFreeChunkId = getNextFreeChunkId(this.usedChunkIds) + 1;
			let index = nextFreeChunkId;
			while(index--) {
				if(this.usedChunkIds[index] !== index) {
					unusedIds.push(index);
				}
			}
		}
 
		const chunks = this.chunks;
		for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
			const chunk = chunks[indexChunk];
			if(chunk.id === null) {
				if(unusedIds.length > 0)
					chunk.id = unusedIds.pop();
				else
					chunk.id = nextFreeChunkId++;
			}
			if(!chunk.ids) {
				chunk.ids = [chunk.id];
			}
		}
	}
 
	sortItemsWithModuleIds() {
		this.modules.sort(byId);
 
		const modules = this.modules;
		for(let indexModule = 0; indexModule < modules.length; indexModule++) {
			modules[indexModule].sortItems();
		}
 
		const chunks = this.chunks;
		for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
			chunks[indexChunk].sortItems();
		}
	}
 
	sortItemsWithChunkIds() {
		this.chunks.sort(byId);
 
		const modules = this.modules;
		for(let indexModule = 0; indexModule < modules.length; indexModule++) {
			modules[indexModule].sortItems();
		}
 
		const chunks = this.chunks;
		for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
			chunks[indexChunk].sortItems();
		}
	}
 
	summarizeDependencies() {
		function filterDups(array) {
			const newArray = [];
			for(let i = 0; i < array.length; i++) {
				if(i === 0 || array[i - 1] !== array[i])
					newArray.push(array[i]);
			}
			return newArray;
		}
		this.fileDependencies = (this.compilationDependencies || []).slice();
		this.contextDependencies = [];
		this.missingDependencies = [];
 
		const children = this.children;
		for(let indexChildren = 0; indexChildren < children.length; indexChildren++) {
			const child = children[indexChildren];
 
			this.fileDependencies = this.fileDependencies.concat(child.fileDependencies);
			this.contextDependencies = this.contextDependencies.concat(child.contextDependencies);
			this.missingDependencies = this.missingDependencies.concat(child.missingDependencies);
		}
 
		const modules = this.modules;
		for(let indexModule = 0; indexModule < modules.length; indexModule++) {
			const module = modules[indexModule];
 
			if(module.fileDependencies) {
				const fileDependencies = module.fileDependencies;
				for(let indexFileDep = 0; indexFileDep < fileDependencies.length; indexFileDep++) {
					this.fileDependencies.push(fileDependencies[indexFileDep]);
				}
			}
			if(module.contextDependencies) {
				const contextDependencies = module.contextDependencies;
				for(let indexContextDep = 0; indexContextDep < contextDependencies.length; indexContextDep++) {
					this.contextDependencies.push(contextDependencies[indexContextDep]);
				}
			}
		}
		this.errors.forEach(error => {
			if(Array.isArray(error.missing)) {
				error.missing.forEach(item => this.missingDependencies.push(item));
			}
		});
		this.fileDependencies.sort();
		this.fileDependencies = filterDups(this.fileDependencies);
		this.contextDependencies.sort();
		this.contextDependencies = filterDups(this.contextDependencies);
		this.missingDependencies.sort();
		this.missingDependencies = filterDups(this.missingDependencies);
	}
 
	createHash() {
		const outputOptions = this.outputOptions;
		const hashFunction = outputOptions.hashFunction;
		const hashDigest = outputOptions.hashDigest;
		const hashDigestLength = outputOptions.hashDigestLength;
		const hash = crypto.createHash(hashFunction);
		if(outputOptions.hashSalt)
			hash.update(outputOptions.hashSalt);
		this.mainTemplate.updateHash(hash);
		this.chunkTemplate.updateHash(hash);
		this.moduleTemplate.updateHash(hash);
		this.children.forEach(function(child) {
			hash.update(child.hash);
		});
		// clone needed as sort below is inplace mutation
		const chunks = this.chunks.slice();
		/**
		 * sort here will bring all "falsy" values to the beginning
		 * this is needed as the "hasRuntime()" chunks are dependent on the
		 * hashes of the non-runtime chunks.
		 */
		chunks.sort((a, b) => {
			const aEntry = a.hasRuntime();
			const bEntry = b.hasRuntime();
			if(aEntry && !bEntry) return 1;
			if(!aEntry && bEntry) return -1;
			return 0;
		});
		for(let i = 0; i < chunks.length; i++) {
			const chunk = chunks[i];
			const chunkHash = crypto.createHash(hashFunction);
			if(outputOptions.hashSalt)
				chunkHash.update(outputOptions.hashSalt);
			chunk.updateHash(chunkHash);
			if(chunk.hasRuntime()) {
				this.mainTemplate.updateHashForChunk(chunkHash, chunk);
			} else {
				this.chunkTemplate.updateHashForChunk(chunkHash, chunk);
			}
			this.applyPlugins2("chunk-hash", chunk, chunkHash);
			chunk.hash = chunkHash.digest(hashDigest);
			hash.update(chunk.hash);
			chunk.renderedHash = chunk.hash.substr(0, hashDigestLength);
		}
		this.fullHash = hash.digest(hashDigest);
		this.hash = this.fullHash.substr(0, hashDigestLength);
	}
 
	modifyHash(update) {
		const outputOptions = this.outputOptions;
		const hashFunction = outputOptions.hashFunction;
		const hashDigest = outputOptions.hashDigest;
		const hashDigestLength = outputOptions.hashDigestLength;
		const hash = crypto.createHash(hashFunction);
		hash.update(this.fullHash);
		hash.update(update);
		this.fullHash = hash.digest(hashDigest);
		this.hash = this.fullHash.substr(0, hashDigestLength);
	}
 
	createModuleAssets() {
		for(let i = 0; i < this.modules.length; i++) {
			const module = this.modules[i];
			if(module.assets) {
				Object.keys(module.assets).forEach((assetName) => {
					const fileName = this.getPath(assetName);
					this.assets[fileName] = module.assets[assetName];
					this.applyPlugins2("module-asset", module, fileName);
				});
			}
		}
	}
 
	createChunkAssets() {
		const outputOptions = this.outputOptions;
		const filename = outputOptions.filename;
		const chunkFilename = outputOptions.chunkFilename;
		for(let i = 0; i < this.chunks.length; i++) {
			const chunk = this.chunks[i];
			chunk.files = [];
			const chunkHash = chunk.hash;
			let source;
			let file;
			const filenameTemplate = chunk.filenameTemplate ? chunk.filenameTemplate :
				chunk.isInitial() ? filename :
				chunkFilename;
			try {
				const useChunkHash = !chunk.hasRuntime() || (this.mainTemplate.useChunkHash && this.mainTemplate.useChunkHash(chunk));
				const usedHash = useChunkHash ? chunkHash : this.fullHash;
				const cacheName = "c" + chunk.id;
				if(this.cache && this.cache[cacheName] && this.cache[cacheName].hash === usedHash) {
					source = this.cache[cacheName].source;
				} else {
					if(chunk.hasRuntime()) {
						source = this.mainTemplate.render(this.hash, chunk, this.moduleTemplate, this.dependencyTemplates);
					} else {
						source = this.chunkTemplate.render(chunk, this.moduleTemplate, this.dependencyTemplates);
					}
					if(this.cache) {
						this.cache[cacheName] = {
							hash: usedHash,
							source: source = (source instanceof CachedSource ? source : new CachedSource(source))
						};
					}
				}
				file = this.getPath(filenameTemplate, {
					noChunkHash: !useChunkHash,
					chunk
				});
				if(this.assets[file])
					throw new Error(`Conflict: Multiple assets emit to the same filename ${file}`);
				this.assets[file] = source;
				chunk.files.push(file);
				this.applyPlugins2("chunk-asset", chunk, file);
			} catch(err) {
				this.errors.push(new ChunkRenderError(chunk, file || filenameTemplate, err));
			}
		}
	}
 
	getPath(filename, data) {
		data = data || {};
		data.hash = data.hash || this.hash;
		return this.mainTemplate.applyPluginsWaterfall("asset-path", filename, data);
	}
 
	getStats() {
		return new Stats(this);
	}
 
	createChildCompiler(name, outputOptions) {
		return this.compiler.createChildCompiler(this, name, outputOptions);
	}
 
	checkConstraints() {
		const usedIds = {};
 
		const modules = this.modules;
		for(let indexModule = 0; indexModule < modules.length; indexModule++) {
			const moduleId = modules[indexModule].id;
 
			if(usedIds[moduleId])
				throw new Error(`checkConstraints: duplicate module id ${moduleId}`);
		}
 
		const chunks = this.chunks;
		for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
			const chunk = chunks[indexChunk];
 
			if(chunks.indexOf(chunk) !== indexChunk)
				throw new Error(`checkConstraints: duplicate chunk in compilation ${chunk.debugId}`);
			chunk.checkConstraints();
		}
	}
}
 
module.exports = Compilation;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Compiler.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Compiler.js

Statements: 10.09% (35 / 347)      Branches: 0% (0 / 134)      Functions: 0% (0 / 63)      Lines: 11.29% (35 / 310)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501        1 1   1   1 1   1                                                   1                                                                                     1                                   1                             1                           1                                               1                                                                                                       1   1 1   1 1             1                                                                                                                   1                                     1         1                 1                               1                                                   1                   1                         1         1                                                   1                                                     1       1       1                       1           1           1                 1                                                        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var path = require("path");
var Tapable = require("tapable");
 
var Compilation = require("./Compilation");
 
var NormalModuleFactory = require("./NormalModuleFactory");
var ContextModuleFactory = require("./ContextModuleFactory");
 
function Watching(compiler, watchOptions, handler) {
	this.startTime = null;
	this.invalid = false;
	this.error = null;
	this.stats = null;
	this.handler = handler;
	this.closed = false;
	if(typeof watchOptions === "number") {
		this.watchOptions = {
			aggregateTimeout: watchOptions
		};
	} else if(watchOptions && typeof watchOptions === "object") {
		this.watchOptions = Object.assign({}, watchOptions);
	} else {
		this.watchOptions = {};
	}
	this.watchOptions.aggregateTimeout = this.watchOptions.aggregateTimeout || 200;
	this.compiler = compiler;
	this.running = true;
	this.compiler.readRecords(function(err) {
		if(err) return this._done(err);
 
		this._go();
	}.bind(this));
}
 
Watching.prototype._go = function() {
	var self = this;
	self.startTime = new Date().getTime();
	self.running = true;
	self.invalid = false;
	self.compiler.applyPluginsAsync("watch-run", self, function(err) {
		if(err) return self._done(err);
		self.compiler.compile(function onCompiled(err, compilation) {
			if(err) return self._done(err);
			if(self.invalid) return self._done();
 
			if(self.compiler.applyPluginsBailResult("should-emit", compilation) === false) {
				return self._done(null, compilation);
			}
 
			self.compiler.emitAssets(compilation, function(err) {
				if(err) return self._done(err);
				if(self.invalid) return self._done();
 
				self.compiler.emitRecords(function(err) {
					if(err) return self._done(err);
 
					if(compilation.applyPluginsBailResult("need-additional-pass")) {
						compilation.needAdditionalPass = true;
 
						var stats = compilation.getStats();
						stats.startTime = self.startTime;
						stats.endTime = new Date().getTime();
						self.compiler.applyPlugins("done", stats);
 
						self.compiler.applyPluginsAsync("additional-pass", function(err) {
							if(err) return self._done(err);
							self.compiler.compile(onCompiled);
						});
						return;
					}
					return self._done(null, compilation);
				});
			});
		});
	});
};
 
Watching.prototype._done = function(err, compilation) {
	this.running = false;
	if(this.invalid) return this._go();
	this.error = err || null;
	this.stats = compilation ? compilation.getStats() : null;
	if(this.stats) {
		this.stats.startTime = this.startTime;
		this.stats.endTime = new Date().getTime();
	}
	if(this.stats)
		this.compiler.applyPlugins("done", this.stats);
	else
		this.compiler.applyPlugins("failed", this.error);
	this.handler(this.error, this.stats);
	if(!this.error && !this.closed)
		this.watch(compilation.fileDependencies, compilation.contextDependencies, compilation.missingDependencies);
};
 
Watching.prototype.watch = function(files, dirs, missing) {
	this.pausedWatcher = null;
	this.watcher = this.compiler.watchFileSystem.watch(files, dirs, missing, this.startTime, this.watchOptions, function(err, filesModified, contextModified, missingModified, fileTimestamps, contextTimestamps) {
		this.pausedWatcher = this.watcher;
		this.watcher = null;
		if(err) return this.handler(err);
 
		this.compiler.fileTimestamps = fileTimestamps;
		this.compiler.contextTimestamps = contextTimestamps;
		this.invalidate();
	}.bind(this), function(fileName, changeTime) {
		this.compiler.applyPlugins("invalid", fileName, changeTime);
	}.bind(this));
};
 
Watching.prototype.invalidate = function() {
	if(this.watcher) {
		this.pausedWatcher = this.watcher;
		this.watcher.pause();
		this.watcher = null;
	}
	if(this.running) {
		this.invalid = true;
		return false;
	} else {
		this._go();
	}
};
 
Watching.prototype.close = function(callback) {
	if(callback === undefined) callback = function() {};
 
	this.closed = true;
	if(this.watcher) {
		this.watcher.close();
		this.watcher = null;
	}
	if(this.pausedWatcher) {
		this.pausedWatcher.close();
		this.pausedWatcher = null;
	}
	if(this.running) {
		this.invalid = true;
		this._done = () => {
			this.compiler.applyPlugins("watch-close");
			callback();
		};
	} else {
		this.compiler.applyPlugins("watch-close");
		callback();
	}
};
 
function Compiler() {
	Tapable.call(this);
 
	this.outputPath = "";
	this.outputFileSystem = null;
	this.inputFileSystem = null;
 
	this.recordsInputPath = null;
	this.recordsOutputPath = null;
	this.records = {};
 
	this.fileTimestamps = {};
	this.contextTimestamps = {};
 
	this.resolvers = {
		normal: null,
		loader: null,
		context: null
	};
	var deprecationReported = false;
	this.parser = {
		plugin: function(hook, fn) {
			if(!deprecationReported) {
				console.warn("webpack: Using compiler.parser is deprecated.\n" +
					"Use compiler.plugin(\"compilation\", function(compilation, data) {\n  data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.plugin(/* ... */); });\n}); instead. " +
					"It was called " + new Error().stack.split("\n")[2].trim() + ".");
				deprecationReported = true;
			}
			this.plugin("compilation", function(compilation, data) {
				data.normalModuleFactory.plugin("parser", function(parser) {
					parser.plugin(hook, fn);
				});
			});
		}.bind(this),
		apply: function() {
			var args = arguments;
			if(!deprecationReported) {
				console.warn("webpack: Using compiler.parser is deprecated.\n" +
					"Use compiler.plugin(\"compilation\", function(compilation, data) {\n  data.normalModuleFactory.plugin(\"parser\", function(parser, options) { parser.apply(/* ... */); });\n}); instead. " +
					"It was called " + new Error().stack.split("\n")[2].trim() + ".");
				deprecationReported = true;
			}
			this.plugin("compilation", function(compilation, data) {
				data.normalModuleFactory.plugin("parser", function(parser) {
					parser.apply.apply(parser, args);
				});
			});
		}.bind(this)
	};
 
	this.options = {};
}
module.exports = Compiler;
 
Compiler.prototype = Object.create(Tapable.prototype);
Compiler.prototype.constructor = Compiler;
 
Compiler.Watching = Watching;
Compiler.prototype.watch = function(watchOptions, handler) {
	this.fileTimestamps = {};
	this.contextTimestamps = {};
	var watching = new Watching(this, watchOptions, handler);
	return watching;
};
 
Compiler.prototype.run = function(callback) {
	var self = this;
	var startTime = new Date().getTime();
 
	self.applyPluginsAsync("before-run", self, function(err) {
		if(err) return callback(err);
 
		self.applyPluginsAsync("run", self, function(err) {
			if(err) return callback(err);
 
			self.readRecords(function(err) {
				if(err) return callback(err);
 
				self.compile(function onCompiled(err, compilation) {
					if(err) return callback(err);
 
					if(self.applyPluginsBailResult("should-emit", compilation) === false) {
						var stats = compilation.getStats();
						stats.startTime = startTime;
						stats.endTime = new Date().getTime();
						self.applyPlugins("done", stats);
						return callback(null, stats);
					}
 
					self.emitAssets(compilation, function(err) {
						if(err) return callback(err);
 
						if(compilation.applyPluginsBailResult("need-additional-pass")) {
							compilation.needAdditionalPass = true;
 
							var stats = compilation.getStats();
							stats.startTime = startTime;
							stats.endTime = new Date().getTime();
							self.applyPlugins("done", stats);
 
							self.applyPluginsAsync("additional-pass", function(err) {
								if(err) return callback(err);
								self.compile(onCompiled);
							});
							return;
						}
 
						self.emitRecords(function(err) {
							if(err) return callback(err);
 
							var stats = compilation.getStats();
							stats.startTime = startTime;
							stats.endTime = new Date().getTime();
							self.applyPlugins("done", stats);
							return callback(null, stats);
						});
					});
				});
			});
		});
	});
};
 
Compiler.prototype.runAsChild = function(callback) {
	this.compile(function(err, compilation) {
		if(err) return callback(err);
 
		this.parentCompilation.children.push(compilation);
		Object.keys(compilation.assets).forEach(function(name) {
			this.parentCompilation.assets[name] = compilation.assets[name];
		}.bind(this));
 
		var entries = Object.keys(compilation.entrypoints).map(function(name) {
			return compilation.entrypoints[name].chunks;
		}).reduce(function(array, chunks) {
			return array.concat(chunks);
		}, []);
 
		return callback(null, entries, compilation);
	}.bind(this));
};
 
Compiler.prototype.purgeInputFileSystem = function() {
	if(this.inputFileSystem && this.inputFileSystem.purge)
		this.inputFileSystem.purge();
};
 
Compiler.prototype.emitAssets = function(compilation, callback) {
	var outputPath;
 
	this.applyPluginsAsync("emit", compilation, function(err) {
		if(err) return callback(err);
		outputPath = compilation.getPath(this.outputPath);
		this.outputFileSystem.mkdirp(outputPath, emitFiles.bind(this));
	}.bind(this));
 
	function emitFiles(err) {
		if(err) return callback(err);
 
		require("async").forEach(Object.keys(compilation.assets), function(file, callback) {
 
			var targetFile = file;
			var queryStringIdx = targetFile.indexOf("?");
			if(queryStringIdx >= 0) {
				targetFile = targetFile.substr(0, queryStringIdx);
			}
 
			if(targetFile.match(/\/|\\/)) {
				var dir = path.dirname(targetFile);
				this.outputFileSystem.mkdirp(this.outputFileSystem.join(outputPath, dir), writeOut.bind(this));
			} else writeOut.call(this);
 
			function writeOut(err) {
				if(err) return callback(err);
				var targetPath = this.outputFileSystem.join(outputPath, targetFile);
				var source = compilation.assets[file];
				if(source.existsAt === targetPath) {
					source.emitted = false;
					return callback();
				}
				var content = source.source();
 
				if(!Buffer.isBuffer(content)) {
					content = new Buffer(content, "utf8"); //eslint-disable-line
				}
 
				source.existsAt = targetPath;
				source.emitted = true;
				this.outputFileSystem.writeFile(targetPath, content, callback);
			}
 
		}.bind(this), function(err) {
			if(err) return callback(err);
 
			afterEmit.call(this);
		}.bind(this));
	}
 
	function afterEmit() {
		this.applyPluginsAsyncSeries1("after-emit", compilation, function(err) {
			if(err) return callback(err);
 
			return callback();
		});
	}
 
};
 
Compiler.prototype.emitRecords = function emitRecords(callback) {
	if(!this.recordsOutputPath) return callback();
	var idx1 = this.recordsOutputPath.lastIndexOf("/");
	var idx2 = this.recordsOutputPath.lastIndexOf("\\");
	var recordsOutputPathDirectory = null;
	if(idx1 > idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx1);
	if(idx1 < idx2) recordsOutputPathDirectory = this.recordsOutputPath.substr(0, idx2);
	if(!recordsOutputPathDirectory) return writeFile.call(this);
	this.outputFileSystem.mkdirp(recordsOutputPathDirectory, function(err) {
		if(err) return callback(err);
		writeFile.call(this);
	}.bind(this));
 
	function writeFile() {
		this.outputFileSystem.writeFile(this.recordsOutputPath, JSON.stringify(this.records, undefined, 2), callback);
	}
};
 
Compiler.prototype.readRecords = function readRecords(callback) {
	var self = this;
	if(!self.recordsInputPath) {
		self.records = {};
		return callback();
	}
	self.inputFileSystem.stat(self.recordsInputPath, function(err) {
		// It doesn't exist
		// We can ignore self.
		if(err) return callback();
 
		self.inputFileSystem.readFile(self.recordsInputPath, function(err, content) {
			if(err) return callback(err);
 
			try {
				self.records = JSON.parse(content.toString("utf-8"));
			} catch(e) {
				e.message = "Cannot parse records: " + e.message;
				return callback(e);
			}
 
			return callback();
		});
	});
};
 
Compiler.prototype.createChildCompiler = function(compilation, compilerName, outputOptions, plugins) {
	var childCompiler = new Compiler();
	if(Array.isArray(plugins)) {
		plugins.forEach(plugin => childCompiler.apply(plugin));
	}
	for(var name in this._plugins) {
		if(["make", "compile", "emit", "after-emit", "invalid", "done", "this-compilation"].indexOf(name) < 0)
			childCompiler._plugins[name] = this._plugins[name].slice();
	}
	childCompiler.name = compilerName;
	childCompiler.outputPath = this.outputPath;
	childCompiler.inputFileSystem = this.inputFileSystem;
	childCompiler.outputFileSystem = null;
	childCompiler.resolvers = this.resolvers;
	childCompiler.fileTimestamps = this.fileTimestamps;
	childCompiler.contextTimestamps = this.contextTimestamps;
	if(!this.records[compilerName]) this.records[compilerName] = [];
	this.records[compilerName].push(childCompiler.records = {});
	childCompiler.options = Object.create(this.options);
	childCompiler.options.output = Object.create(childCompiler.options.output);
	for(name in outputOptions) {
		childCompiler.options.output[name] = outputOptions[name];
	}
	childCompiler.parentCompilation = compilation;
	return childCompiler;
};
 
Compiler.prototype.isChild = function() {
	return !!this.parentCompilation;
};
 
Compiler.prototype.createCompilation = function() {
	return new Compilation(this);
};
 
Compiler.prototype.newCompilation = function(params) {
	var compilation = this.createCompilation();
	compilation.fileTimestamps = this.fileTimestamps;
	compilation.contextTimestamps = this.contextTimestamps;
	compilation.name = this.name;
	compilation.records = this.records;
	compilation.compilationDependencies = params.compilationDependencies;
	this.applyPlugins("this-compilation", compilation, params);
	this.applyPlugins("compilation", compilation, params);
	return compilation;
};
 
Compiler.prototype.createNormalModuleFactory = function() {
	var normalModuleFactory = new NormalModuleFactory(this.options.context, this.resolvers, this.options.module || {});
	this.applyPlugins("normal-module-factory", normalModuleFactory);
	return normalModuleFactory;
};
 
Compiler.prototype.createContextModuleFactory = function() {
	var contextModuleFactory = new ContextModuleFactory(this.resolvers, this.inputFileSystem);
	this.applyPlugins("context-module-factory", contextModuleFactory);
	return contextModuleFactory;
};
 
Compiler.prototype.newCompilationParams = function() {
	var params = {
		normalModuleFactory: this.createNormalModuleFactory(),
		contextModuleFactory: this.createContextModuleFactory(),
		compilationDependencies: []
	};
	return params;
};
 
Compiler.prototype.compile = function(callback) {
	var self = this;
	var params = self.newCompilationParams();
	self.applyPluginsAsync("before-compile", params, function(err) {
		if(err) return callback(err);
 
		self.applyPlugins("compile", params);
 
		var compilation = self.newCompilation(params);
 
		self.applyPluginsParallel("make", compilation, function(err) {
			if(err) return callback(err);
 
			compilation.finish();
 
			compilation.seal(function(err) {
				if(err) return callback(err);
 
				self.applyPluginsAsync("after-compile", compilation, function(err) {
					if(err) return callback(err);
 
					return callback(null, compilation);
				});
			});
		});
	});
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ConstPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ConstPlugin.js

Statements: 13.16% (5 / 38)      Branches: 0% (0 / 14)      Functions: 0% (0 / 5)      Lines: 13.89% (5 / 36)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62          1 1 1   1                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ConstDependency = require("./dependencies/ConstDependency");
const NullFactory = require("./NullFactory");
const ParserHelpers = require("./ParserHelpers");
 
const getQuery = (request) => {
	const i = request.indexOf("?");
	return request.indexOf("?") < 0 ? "" : request.substr(i);
};
 
class ConstPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 
			params.normalModuleFactory.plugin("parser", parser => {
				parser.plugin("statement if", function(statement) {
					const param = this.evaluateExpression(statement.test);
					const bool = param.asBool();
					if(typeof bool === "boolean") {
						if(statement.test.type !== "Literal") {
							const dep = new ConstDependency(`${bool}`, param.range);
							dep.loc = statement.loc;
							this.state.current.addDependency(dep);
						}
						return bool;
					}
				});
				parser.plugin("expression ?:", function(expression) {
					const param = this.evaluateExpression(expression.test);
					const bool = param.asBool();
					if(typeof bool === "boolean") {
						if(expression.test.type !== "Literal") {
							const dep = new ConstDependency(` ${bool}`, param.range);
							dep.loc = expression.loc;
							this.state.current.addDependency(dep);
						}
						return bool;
					}
				});
				parser.plugin("evaluate Identifier __resourceQuery", function(expr) {
					if(!this.state.module) return;
					return ParserHelpers.evaluateToString(getQuery(this.state.module.resource))(expr);
				});
				parser.plugin("expression __resourceQuery", function() {
					if(!this.state.module) return;
					this.state.current.addVariable("__resourceQuery", JSON.stringify(getQuery(this.state.module.resource)));
					return true;
				});
			});
		});
	}
}
 
module.exports = ConstPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ContextModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ContextModule.js

Statements: 5.08% (6 / 118)      Branches: 0% (0 / 60)      Functions: 0% (0 / 17)      Lines: 5.17% (6 / 116)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259          1 1 1 1 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const path = require("path");
const Module = require("./Module");
const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
 
class ContextModule extends Module {
	constructor(resolveDependencies, context, recursive, regExp, addon, isAsync, chunkName) {
		super();
		this.resolveDependencies = resolveDependencies;
		this.context = context;
		this.recursive = recursive;
		this.regExp = regExp;
		this.addon = addon;
		this.async = !!isAsync;
		this.cacheable = true;
		this.contextDependencies = [context];
		this.built = false;
		this.chunkName = chunkName;
	}
 
	prettyRegExp(regexString) {
		// remove the "/" at the front and the beginning
		// "/foo/" -> "foo"
		return regexString.substring(1, regexString.length - 1);
	}
 
	contextify(context, request) {
		return request.split("!").map(subrequest => {
			let rp = path.relative(context, subrequest);
			if(path.sep === "\\")
				rp = rp.replace(/\\/g, "/");
			if(rp.indexOf("../") !== 0)
				rp = "./" + rp;
			return rp;
		}).join("!");
	}
 
	identifier() {
		let identifier = this.context;
		if(this.async)
			identifier += " async";
		if(!this.recursive)
			identifier += " nonrecursive";
		if(this.addon)
			identifier += ` ${this.addon}`;
		if(this.regExp)
			identifier += ` ${this.regExp}`;
 
		return identifier;
	}
 
	readableIdentifier(requestShortener) {
		let identifier = requestShortener.shorten(this.context);
		if(this.async)
			identifier += " async";
		if(!this.recursive)
			identifier += " nonrecursive";
		if(this.addon)
			identifier += ` ${requestShortener.shorten(this.addon)}`;
		if(this.regExp)
			identifier += ` ${this.prettyRegExp(this.regExp + "")}`;
 
		return identifier;
	}
 
	libIdent(options) {
		let identifier = this.contextify(options.context, this.context);
		if(this.async)
			identifier += " async";
		if(this.recursive)
			identifier += " recursive";
		if(this.addon)
			identifier += ` ${this.contextify(options.context, this.addon)}`;
		if(this.regExp)
			identifier += ` ${this.prettyRegExp(this.regExp + "")}`;
 
		return identifier;
	}
 
	needRebuild(fileTimestamps, contextTimestamps) {
		const ts = contextTimestamps[this.context];
		if(!ts) {
			return true;
		}
 
		return ts >= this.builtTime;
	}
 
	unbuild() {
		this.built = false;
		super.unbuild();
	}
 
	build(options, compilation, resolver, fs, callback) {
		this.built = true;
		this.builtTime = new Date().getTime();
		this.resolveDependencies(fs, this.context, this.recursive, this.regExp, (err, dependencies) => {
			if(err) return callback(err);
 
			if(!dependencies) {
				this.dependencies = [];
				callback();
				return;
			}
 
			// enhance dependencies
			dependencies.forEach(dep => {
				dep.loc = dep.userRequest;
				dep.request = this.addon + dep.request;
			});
 
			// if these we are not a async context
			// add dependencies and continue
			if(!this.async) {
				this.dependencies = dependencies;
				callback();
				return;
			}
 
			// if we are async however create a new async dependency block
			// and add that block to this context
			dependencies.forEach(dep => {
				const block = new AsyncDependenciesBlock(this.chunkName, dep.module, dep.loc);
				block.addDependency(dep);
				this.addBlock(block);
			});
			callback();
		});
	}
 
	getSourceWithDependencies(dependencies, id) {
		// if we filter first we get a new array
		// therefor we dont need to create a clone of dependencies explicitly
		// therefore the order of this is !important!
		const map = dependencies
			.filter(dependency => dependency.module)
			.sort((a, b) => {
				if(a.userRequest === b.userRequest) {
					return 0;
				}
				return a.userRequest < b.userRequest ? -1 : 1;
			}).reduce(function(map, dep) {
				map[dep.userRequest] = dep.module.id;
				return map;
			}, Object.create(null));
		return `var map = ${JSON.stringify(map, null, "\t")};
function webpackContext(req) {
	return __webpack_require__(webpackContextResolve(req));
};
function webpackContextResolve(req) {
	var id = map[req];
	if(!(id + 1)) // check for number or string
		throw new Error("Cannot find module '" + req + "'.");
	return id;
};
webpackContext.keys = function webpackContextKeys() {
	return Object.keys(map);
};
webpackContext.resolve = webpackContextResolve;
module.exports = webpackContext;
webpackContext.id = ${JSON.stringify(id)};`;
	}
 
	getSourceWithBlocks(blocks, id) {
		let hasMultipleOrNoChunks = false;
		const map = blocks
			.filter(block => block.dependencies[0].module)
			.map((block) => ({
				dependency: block.dependencies[0],
				block: block,
				userRequest: block.dependencies[0].userRequest
			})).sort((a, b) => {
				if(a.userRequest === b.userRequest) return 0;
				return a.userRequest < b.userRequest ? -1 : 1;
			}).reduce((map, item) => {
				const chunks = item.block.chunks || [];
				if(chunks.length !== 1) {
					hasMultipleOrNoChunks = true;
				}
				map[item.userRequest] = [item.dependency.module.id]
					.concat(chunks.map(chunk => chunk.id));
 
				return map;
			}, Object.create(null));
 
		const requestPrefix = hasMultipleOrNoChunks ?
			"Promise.all(ids.slice(1).map(__webpack_require__.e))" :
			"__webpack_require__.e(ids[1])";
 
		return `var map = ${JSON.stringify(map, null, "\t")};
function webpackAsyncContext(req) {
	var ids = map[req];
	if(!ids)
		return Promise.reject(new Error("Cannot find module '" + req + "'."));
	return ${requestPrefix}.then(function() {
		return __webpack_require__(ids[0]);
	});
};
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
	return Object.keys(map);
};
module.exports = webpackAsyncContext;
webpackAsyncContext.id = ${JSON.stringify(id)};`;
	}
 
	getSourceForEmptyContext(id) {
		return `function webpackEmptyContext(req) {
	throw new Error("Cannot find module '" + req + "'.");
}
webpackEmptyContext.keys = function() { return []; };
webpackEmptyContext.resolve = webpackEmptyContext;
module.exports = webpackEmptyContext;
webpackEmptyContext.id = ${JSON.stringify(id)};`;
	}
 
	getSourceString() {
		if(this.dependencies && this.dependencies.length > 0) {
			return this.getSourceWithDependencies(this.dependencies, this.id);
		}
 
		if(this.blocks && this.blocks.length > 0) {
			return this.getSourceWithBlocks(this.blocks, this.id);
		}
 
		return this.getSourceForEmptyContext(this.id);
	}
 
	getSource(sourceString) {
		if(this.useSourceMap) {
			return new OriginalSource(sourceString, this.identifier());
		}
		return new RawSource(sourceString);
	}
 
	source() {
		return this.getSource(
			this.getSourceString()
		);
	}
 
	size() {
		// base penalty
		const initialSize = 160;
 
		// if we dont have dependencies we stop here.
		return this.dependencies
			.reduce((size, dependency) => size + 5 + dependency.userRequest.length, initialSize);
	}
}
 
module.exports = ContextModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ContextModuleFactory.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ContextModuleFactory.js

Statements: 11.34% (11 / 97)      Branches: 0% (0 / 46)      Functions: 0% (0 / 22)      Lines: 13.41% (11 / 82)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161        1 1   1 1 1   1       1   1 1   1                                                                                                                                                                 1                                                                                                                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var asyncLib = require("async");
var path = require("path");
 
var Tapable = require("tapable");
var ContextModule = require("./ContextModule");
var ContextElementDependency = require("./dependencies/ContextElementDependency");
 
function ContextModuleFactory(resolvers) {
	Tapable.call(this);
	this.resolvers = resolvers;
}
module.exports = ContextModuleFactory;
 
ContextModuleFactory.prototype = Object.create(Tapable.prototype);
ContextModuleFactory.prototype.constructor = ContextModuleFactory;
 
ContextModuleFactory.prototype.create = function(data, callback) {
	var module = this;
	var context = data.context;
	var dependencies = data.dependencies;
	var dependency = dependencies[0];
	this.applyPluginsAsyncWaterfall("before-resolve", {
		context: context,
		request: dependency.request,
		recursive: dependency.recursive,
		regExp: dependency.regExp,
		async: dependency.async,
		dependencies: dependencies
	}, function(err, result) {
		if(err) return callback(err);
 
		// Ignored
		if(!result) return callback();
 
		var context = result.context;
		var request = result.request;
		var recursive = result.recursive;
		var regExp = result.regExp;
		var asyncContext = result.async;
		var dependencies = result.dependencies;
 
		var loaders, resource, loadersPrefix = "";
		var idx = request.lastIndexOf("!");
		if(idx >= 0) {
			loaders = request.substr(0, idx + 1);
			for(var i = 0; i < loaders.length && loaders[i] === "!"; i++) {
				loadersPrefix += "!";
			}
			loaders = loaders.substr(i).replace(/!+$/, "").replace(/!!+/g, "!");
			if(loaders === "") loaders = [];
			else loaders = loaders.split("!");
			resource = request.substr(idx + 1);
		} else {
			loaders = [];
			resource = request;
		}
 
		var resolvers = module.resolvers;
 
		asyncLib.parallel([
			function(callback) {
				resolvers.context.resolve({}, context, resource, function(err, result) {
					if(err) return callback(err);
					callback(null, result);
				});
			},
			function(callback) {
				asyncLib.map(loaders, function(loader, callback) {
					resolvers.loader.resolve({}, context, loader, function(err, result) {
						if(err) return callback(err);
						callback(null, result);
					});
				}, callback);
			}
		], function(err, result) {
			if(err) return callback(err);
 
			module.applyPluginsAsyncWaterfall("after-resolve", {
				loaders: loadersPrefix + result[1].join("!") + (result[1].length > 0 ? "!" : ""),
				resource: result[0],
				recursive: recursive,
				regExp: regExp,
				async: asyncContext,
				dependencies: dependencies,
				resolveDependencies: module.resolveDependencies.bind(module)
			}, function(err, result) {
				if(err) return callback(err);
 
				// Ignored
				if(!result) return callback();
 
				return callback(null, new ContextModule(result.resolveDependencies, result.resource, result.recursive, result.regExp, result.loaders, result.async, dependency.chunkName));
			});
		});
	});
};
 
ContextModuleFactory.prototype.resolveDependencies = function resolveDependencies(fs, resource, recursive, regExp, callback) {
	if(!regExp || !resource)
		return callback(null, []);
	(function addDirectory(directory, callback) {
		fs.readdir(directory, function(err, files) {
			if(err) return callback(err);
			if(!files || files.length === 0) return callback(null, []);
			asyncLib.map(files.filter(function(p) {
				return p.indexOf(".") !== 0;
			}), function(seqment, callback) {
 
				var subResource = path.join(directory, seqment);
 
				fs.stat(subResource, function(err, stat) {
					if(err) return callback(err);
 
					if(stat.isDirectory()) {
 
						if(!recursive) return callback();
						addDirectory.call(this, subResource, callback);
 
					} else if(stat.isFile()) {
 
						var obj = {
							context: resource,
							request: "." + subResource.substr(resource.length).replace(/\\/g, "/")
						};
 
						this.applyPluginsAsyncWaterfall("alternatives", [obj], function(err, alternatives) {
							if(err) return callback(err);
							alternatives = alternatives.filter(function(obj) {
								return regExp.test(obj.request);
							}).map(function(obj) {
								var dep = new ContextElementDependency(obj.request);
								dep.optional = true;
								return dep;
							});
							callback(null, alternatives);
						});
 
					} else callback();
 
				}.bind(this));
 
			}.bind(this), function(err, result) {
				if(err) return callback(err);
 
				if(!result) return callback(null, []);
 
				callback(null, result.filter(function(i) {
					return !!i;
				}).reduce(function(a, i) {
					return a.concat(i);
				}, []));
			});
		}.bind(this));
	}.call(this, resource, callback));
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ContextReplacementPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ContextReplacementPlugin.js

Statements: 5.33% (4 / 75)      Branches: 0% (0 / 48)      Functions: 0% (0 / 3)      Lines: 5.56% (4 / 72)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113            1 1                                                                                                                                                                                     1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
const ContextElementDependency = require("./dependencies/ContextElementDependency");
 
class ContextReplacementPlugin {
	constructor(resourceRegExp, newContentResource, newContentRecursive, newContentRegExp) {
		this.resourceRegExp = resourceRegExp;
 
		if(typeof newContentResource === "function") {
			this.newContentCallback = newContentResource;
		} else if(typeof newContentResource === "string" && typeof newContentRecursive === "object") {
			this.newContentResource = newContentResource;
			this.newContentCreateContextMap = (fs, callback) => {
				callback(null, newContentRecursive);
			};
		} else if(typeof newContentResource === "string" && typeof newContentRecursive === "function") {
			this.newContentResource = newContentResource;
			this.newContentCreateContextMap = newContentRecursive;
		} else {
			if(typeof newContentResource !== "string") {
				newContentRegExp = newContentRecursive;
				newContentRecursive = newContentResource;
				newContentResource = undefined;
			}
			if(typeof newContentRecursive !== "boolean") {
				newContentRegExp = newContentRecursive;
				newContentRecursive = undefined;
			}
			this.newContentResource = newContentResource;
			this.newContentRecursive = newContentRecursive;
			this.newContentRegExp = newContentRegExp;
		}
	}
 
	apply(compiler) {
		const resourceRegExp = this.resourceRegExp;
		const newContentCallback = this.newContentCallback;
		const newContentResource = this.newContentResource;
		const newContentRecursive = this.newContentRecursive;
		const newContentRegExp = this.newContentRegExp;
		const newContentCreateContextMap = this.newContentCreateContextMap;
 
		compiler.plugin("context-module-factory", (cmf) => {
			cmf.plugin("before-resolve", (result, callback) => {
				if(!result) return callback();
				if(resourceRegExp.test(result.request)) {
					if(typeof newContentResource !== "undefined")
						result.request = newContentResource;
					if(typeof newContentRecursive !== "undefined")
						result.recursive = newContentRecursive;
					if(typeof newContentRegExp !== "undefined")
						result.regExp = newContentRegExp;
					if(typeof newContentCallback === "function") {
						newContentCallback(result);
					} else {
						result.dependencies.forEach((d) => {
							if(d.critical)
								d.critical = false;
						});
					}
				}
				return callback(null, result);
			});
			cmf.plugin("after-resolve", (result, callback) => {
				if(!result) return callback();
				if(resourceRegExp.test(result.resource)) {
					if(typeof newContentResource !== "undefined")
						result.resource = path.resolve(result.resource, newContentResource);
					if(typeof newContentRecursive !== "undefined")
						result.recursive = newContentRecursive;
					if(typeof newContentRegExp !== "undefined")
						result.regExp = newContentRegExp;
					if(typeof newContentCreateContextMap === "function")
						result.resolveDependencies = createResolveDependenciesFromContextMap(newContentCreateContextMap);
					if(typeof newContentCallback === "function") {
						const origResource = result.resource;
						newContentCallback(result);
						if(result.resource !== origResource) {
							result.resource = path.resolve(origResource, result.resource);
						}
					} else {
						result.dependencies.forEach((d) => {
							if(d.critical)
								d.critical = false;
						});
					}
				}
				return callback(null, result);
			});
		});
	}
}
 
const createResolveDependenciesFromContextMap = (createContextMap) => {
	return function resolveDependenciesFromContextMap(fs, resource, recursive, regExp, callback) {
		createContextMap(fs, (err, map) => {
			if(err) return callback(err);
			const dependencies = Object.keys(map).map((key) => {
				return new ContextElementDependency(map[key], key);
			});
			callback(null, dependencies);
		});
	};
};
 
module.exports = ContextReplacementPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DefinePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DefinePlugin.js

Statements: 12.35% (10 / 81)      Branches: 0% (0 / 31)      Functions: 0% (0 / 8)      Lines: 14.08% (10 / 71)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125            1 1 1 1                                                     1             1                 1               1                                                                                                   1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConstDependency = require("./dependencies/ConstDependency");
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
const ParserHelpers = require("./ParserHelpers");
const NullFactory = require("./NullFactory");
 
class DefinePlugin {
	constructor(definitions) {
		this.definitions = definitions;
	}
 
	apply(compiler) {
		const definitions = this.definitions;
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser) => {
				(function walkDefinitions(definitions, prefix) {
					Object.keys(definitions).forEach((key) => {
						const code = definitions[key];
						if(code && typeof code === "object" && !(code instanceof RegExp)) {
							walkDefinitions(code, prefix + key + ".");
							applyObjectDefine(prefix + key, code);
							return;
						}
						applyDefineKey(prefix, key);
						applyDefine(prefix + key, code);
					});
				}(definitions, ""));
 
				function stringifyObj(obj) {
					return "__webpack_require__.i({" + Object.keys(obj).map((key) => {
						const code = obj[key];
						return JSON.stringify(key) + ":" + toCode(code);
					}).join(",") + "})";
				}
 
				function toCode(code) {
					if(code === null) return "null";
					else if(code === undefined) return "undefined";
					else if(code instanceof RegExp && code.toString) return code.toString();
					else if(typeof code === "function" && code.toString) return "(" + code.toString() + ")";
					else if(typeof code === "object") return stringifyObj(code);
					else return code + "";
				}
 
				function applyDefineKey(prefix, key) {
					const splittedKey = key.split(".");
					splittedKey.slice(1).forEach((_, i) => {
						const fullKey = prefix + splittedKey.slice(0, i + 1).join(".");
						parser.plugin("can-rename " + fullKey, ParserHelpers.approve);
					});
				}
 
				function applyDefine(key, code) {
					const isTypeof = /^typeof\s+/.test(key);
					if(isTypeof) key = key.replace(/^typeof\s+/, "");
					let recurse = false;
					let recurseTypeof = false;
					code = toCode(code);
					if(!isTypeof) {
						parser.plugin("can-rename " + key, ParserHelpers.approve);
						parser.plugin("evaluate Identifier " + key, (expr) => {
							/**
							 * this is needed in case there is a recursion in the DefinePlugin
							 * to prevent an endless recursion
							 * e.g.: new DefinePlugin({
							 * "a": "b",
							 * "b": "a"
							 * });
							 */
							if(recurse) return;
							recurse = true;
							const res = parser.evaluate(code);
							recurse = false;
							res.setRange(expr.range);
							return res;
						});
						parser.plugin("expression " + key, ParserHelpers.toConstantDependency(code));
					}
					const typeofCode = isTypeof ? code : "typeof (" + code + ")";
					parser.plugin("evaluate typeof " + key, (expr) => {
						/**
						 * this is needed in case there is a recursion in the DefinePlugin
						 * to prevent an endless recursion
						 * e.g.: new DefinePlugin({
						 * "typeof a": "tyepof b",
						 * "typeof b": "typeof a"
						 * });
						 */
						if(recurseTypeof) return;
						recurseTypeof = true;
						const res = parser.evaluate(typeofCode);
						recurseTypeof = false;
						res.setRange(expr.range);
						return res;
					});
					parser.plugin("typeof " + key, (expr) => {
						const res = parser.evaluate(typeofCode);
						if(!res.isString()) return;
						return ParserHelpers.toConstantDependency(JSON.stringify(res.string)).bind(parser)(expr);
					});
				}
 
				function applyObjectDefine(key, obj) {
					const code = stringifyObj(obj);
					parser.plugin("can-rename " + key, ParserHelpers.approve);
					parser.plugin("evaluate Identifier " + key, (expr) => new BasicEvaluatedExpression().setRange(expr.range));
					parser.plugin("evaluate typeof " + key, ParserHelpers.evaluateToString("object"));
					parser.plugin("expression " + key, ParserHelpers.toConstantDependency(code));
					parser.plugin("typeof " + key, ParserHelpers.toConstantDependency(JSON.stringify("object")));
				}
			});
		});
	}
}
module.exports = DefinePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DelegatedModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DelegatedModule.js

Statements: 14.63% (6 / 41)      Branches: 0% (0 / 8)      Functions: 0% (0 / 8)      Lines: 14.63% (6 / 41)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86            1 1 1 1 1                                                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Module = require("./Module");
const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
 
class DelegatedModule extends Module {
	constructor(sourceRequest, data, type, userRequest) {
		super();
		this.sourceRequest = sourceRequest;
		this.request = data.id;
		this.meta = data.meta;
		this.type = type;
		this.userRequest = userRequest;
		this.built = false;
		this.delegated = true;
		this.delegateData = data;
	}
 
	identifier() {
		return `delegated ${JSON.stringify(this.request)} from ${this.sourceRequest}`;
	}
 
	readableIdentifier() {
		return `delegated ${this.userRequest} from ${this.sourceRequest}`;
	}
 
	needRebuild() {
		return false;
	}
 
	build(options, compilation, resolver, fs, callback) {
		this.built = true;
		this.builtTime = new Date().getTime();
		this.usedExports = true;
		this.providedExports = this.delegateData.exports || true;
		this.dependencies.length = 0;
		this.addDependency(new DelegatedSourceDependency(this.sourceRequest));
		callback();
	}
 
	unbuild() {
		this.built = false;
		super.unbuild();
	}
 
	source() {
		const sourceModule = this.dependencies[0].module;
		let str;
 
		if(!sourceModule) {
			str = WebpackMissingModule.moduleCode(this.sourceRequest);
		} else {
			str = `module.exports = (__webpack_require__(${sourceModule.id}))`;
 
			switch(this.type) {
				case "require":
					str += `(${JSON.stringify(this.request)})`;
					break;
				case "object":
					str += `[${JSON.stringify(this.request)}]`;
					break;
			}
		}
 
		if(this.useSourceMap) {
			return new OriginalSource(str, this.identifier());
		} else {
			return new RawSource(str);
		}
	}
 
	size() {
		return 42;
	}
}
 
module.exports = DelegatedModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DelegatedModuleFactoryPlugin.js

Statements: 6.67% (2 / 30)      Branches: 0% (0 / 20)      Functions: 0% (0 / 2)      Lines: 6.9% (2 / 29)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » DelegatedModuleFactoryPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60            1                                                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const DelegatedModule = require("./DelegatedModule");
 
// options.source
// options.type
// options.context
// options.scope
// options.content
class DelegatedModuleFactoryPlugin {
	constructor(options) {
		this.options = options;
		options.type = options.type || "require";
		options.extensions = options.extensions || ["", ".js"];
	}
 
	apply(normalModuleFactory) {
		const scope = this.options.scope;
		if(scope) {
			normalModuleFactory.plugin("factory", factory => (data, callback) => {
				const dependency = data.dependencies[0];
				const request = dependency.request;
				if(request && request.indexOf(scope + "/") === 0) {
					const innerRequest = "." + request.substr(scope.length);
					let resolved;
					if(innerRequest in this.options.content) {
						resolved = this.options.content[innerRequest];
						return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, innerRequest));
					}
					for(let i = 0; i < this.options.extensions.length; i++) {
						const requestPlusExt = innerRequest + this.options.extensions[i];
						if(requestPlusExt in this.options.content) {
							resolved = this.options.content[requestPlusExt];
							return callback(null, new DelegatedModule(this.options.source, resolved, this.options.type, requestPlusExt));
						}
					}
				}
				return factory(data, callback);
			});
		} else {
			normalModuleFactory.plugin("module", module => {
				if(module.libIdent) {
					const request = module.libIdent(this.options);
					if(request && request in this.options.content) {
						const resolved = this.options.content[request];
						return new DelegatedModule(this.options.source, resolved, this.options.type, request);
					}
				}
				return module;
			});
		}
	}
}
module.exports = DelegatedModuleFactoryPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DelegatedPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DelegatedPlugin.js

Statements: 37.5% (3 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 37.5% (3 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29              1 1                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
 
"use strict";
 
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
 
class DelegatedPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(DelegatedSourceDependency, params.normalModuleFactory);
		});
 
		compiler.plugin("compile", (params) => {
			params.normalModuleFactory.apply(new DelegatedModuleFactoryPlugin(this.options));
		});
	}
}
 
module.exports = DelegatedPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DependenciesBlock.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DependenciesBlock.js

Statements: 14.71% (5 / 34)      Branches: 0% (0 / 10)      Functions: 0% (0 / 12)      Lines: 15.63% (5 / 32)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83            1   1       1                                                           1                                                                           1    
/*
 MIT License http://www.opensource.org/licenses/mit-license.php
 Author Tobias Koppers @sokra
 */
"use strict";
 
const DependenciesBlockVariable = require("./DependenciesBlockVariable");
 
function disconnect(i) {
	i.disconnect();
}
 
function unseal(i) {
	i.unseal();
}
 
class DependenciesBlock {
	constructor() {
		this.dependencies = [];
		this.blocks = [];
		this.variables = [];
	}
 
	addBlock(block) {
		this.blocks.push(block);
		block.parent = this;
	}
 
	addVariable(name, expression, dependencies) {
		for(let v of this.variables) {
			if(v.name === name && v.expression === expression) {
				return;
			}
		}
		this.variables.push(new DependenciesBlockVariable(name, expression, dependencies));
	}
 
	addDependency(dependency) {
		this.dependencies.push(dependency);
	}
 
	updateHash(hash) {
		function updateHash(i) {
			i.updateHash(hash);
		}
 
		this.dependencies.forEach(updateHash);
		this.blocks.forEach(updateHash);
		this.variables.forEach(updateHash);
	}
 
	disconnect() {
		this.dependencies.forEach(disconnect);
		this.blocks.forEach(disconnect);
		this.variables.forEach(disconnect);
	}
 
	unseal() {
		this.blocks.forEach(unseal);
	}
 
	hasDependencies(filter) {
		if(filter) {
			if(this.dependencies.some(filter)) {
				return true;
			}
		} else {
			if(this.dependencies.length > 0) {
				return true;
			}
		}
 
		return this.blocks.concat(this.variables).some(item => item.hasDependencies(filter));
	}
 
	sortItems() {
		this.blocks.forEach(block => block.sortItems());
	}
}
 
module.exports = DependenciesBlock;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DependenciesBlockVariable.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DependenciesBlockVariable.js

Statements: 12% (3 / 25)      Branches: 0% (0 / 10)      Functions: 0% (0 / 5)      Lines: 13.64% (3 / 22)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53            1 1                                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ReplaceSource = require("webpack-sources").ReplaceSource;
const RawSource = require("webpack-sources").RawSource;
 
class DependenciesBlockVariable {
	constructor(name, expression, dependencies) {
		this.name = name;
		this.expression = expression;
		this.dependencies = dependencies || [];
	}
 
	updateHash(hash) {
		hash.update(this.name);
		hash.update(this.expression);
		this.dependencies.forEach(d => {
			d.updateHash(hash);
		});
	}
 
	expressionSource(dependencyTemplates, outputOptions, requestShortener) {
		const source = new ReplaceSource(new RawSource(this.expression));
		this.dependencies.forEach(dep => {
			const template = dependencyTemplates.get(dep.constructor);
			if(!template) throw new Error(`No template for dependency: ${dep.constructor.name}`);
			template.apply(dep, source, outputOptions, requestShortener, dependencyTemplates);
		});
		return source;
	}
 
	disconnect() {
		this.dependencies.forEach(d => {
			d.disconnect();
		});
	}
 
	hasDependencies(filter) {
		if(filter) {
			if(this.dependencies.some(filter)) return true;
		} else {
			if(this.dependencies.length > 0) return true;
		}
		return false;
	}
}
 
module.exports = DependenciesBlockVariable;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Dependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Dependency.js

Statements: 20% (3 / 15)      Branches: 0% (0 / 4)      Functions: 0% (0 / 9)      Lines: 23.08% (3 / 13)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56          1                                                                                           1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const compareLocations = require("./compareLocations");
 
class Dependency {
	constructor() {
		this.module = null;
	}
 
	isEqualResource() {
		return false;
	}
 
	// Returns the referenced module and export
	getReference() {
		if(!this.module) return null;
		return {
			module: this.module,
			importedNames: true, // true: full object, false: only sideeffects/no export, array of strings: the exports with this names
		};
	}
 
	// Returns the exported names
	getExports() {
		return null;
	}
 
	getWarnings() {
		return null;
	}
 
	getErrors() {
		return null;
	}
 
	updateHash(hash) {
		hash.update((this.module && this.module.id) + "");
	}
 
	disconnect() {
		this.module = null;
	}
 
	// TODO: remove in webpack 3
	compare(a, b) {
		return compareLocations(a.loc, b.loc);
	}
}
Dependency.compare = (a, b) => compareLocations(a.loc, b.loc);
 
module.exports = Dependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllEntryPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllEntryPlugin.js

Statements: 23.53% (4 / 17)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 23.53% (4 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39            1 1 1                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const DllEntryDependency = require("./dependencies/DllEntryDependency");
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
const DllModuleFactory = require("./DllModuleFactory");
 
class DllEntryPlugin {
	constructor(context, entries, name) {
		this.context = context;
		this.entries = entries;
		this.name = name;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const dllModuleFactory = new DllModuleFactory();
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(DllEntryDependency, dllModuleFactory);
 
			compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
		});
		compiler.plugin("make", (compilation, callback) => {
			compilation.addEntry(this.context, new DllEntryDependency(this.entries.map((e, idx) => {
				const dep = new SingleEntryDependency(e);
				dep.loc = `${this.name}:${idx}`;
				return dep;
			}), this.name), this.name, callback);
		});
	}
}
 
module.exports = DllEntryPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllModule.js

Statements: 13.64% (3 / 22)      Branches: 0% (0 / 2)      Functions: 0% (0 / 9)      Lines: 13.64% (3 / 22)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60            1 1                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
	*/
"use strict";
 
const Module = require("./Module");
const RawSource = require("webpack-sources").RawSource;
 
class DllModule extends Module {
	constructor(context, dependencies, name, type) {
		super();
		this.context = context;
		this.dependencies = dependencies;
		this.name = name;
		this.built = false;
		this.cacheable = true;
		this.type = type;
	}
 
	identifier() {
		return `dll ${this.name}`;
	}
 
	readableIdentifier() {
		return `dll ${this.name}`;
	}
 
	disconnect() {
		this.built = false;
		super.disconnect();
	}
 
	build(options, compilation, resolver, fs, callback) {
		this.built = true;
		return callback();
	}
 
	source() {
		return new RawSource("module.exports = __webpack_require__;");
	}
 
	needRebuild() {
		return false;
	}
 
	size() {
		return 12;
	}
 
	updateHash(hash) {
		hash.update("dll module");
		hash.update(this.name || "");
		super.updateHash(hash);
	}
}
 
module.exports = DllModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllModuleFactory.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllModuleFactory.js

Statements: 50% (3 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (3 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22            1 1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
var Tapable = require("tapable");
var DllModule = require("./DllModule");
 
class DllModuleFactory extends Tapable {
	constructor() {
		super();
	}
	create(data, callback) {
		const dependency = data.dependencies[0];
		callback(null, new DllModule(data.context, dependency.dependencies, dependency.name, dependency.type));
	}
}
 
module.exports = DllModuleFactory;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllPlugin.js

Statements: 29.41% (5 / 17)      Branches: 0% (0 / 6)      Functions: 0% (0 / 3)      Lines: 29.41% (5 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40            1 1 1                 1                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
	*/
"use strict";
 
const DllEntryPlugin = require("./DllEntryPlugin");
const LibManifestPlugin = require("./LibManifestPlugin");
const FlagInitialModulesAsUsedPlugin = require("./FlagInitialModulesAsUsedPlugin");
 
class DllPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		compiler.plugin("entry-option", (context, entry) => {
			function itemToPlugin(item, name) {
				if(Array.isArray(item))
					return new DllEntryPlugin(context, item, name);
				else
					throw new Error("DllPlugin: supply an Array as entry");
			}
			if(typeof entry === "object" && !Array.isArray(entry)) {
				Object.keys(entry).forEach(name => {
					compiler.apply(itemToPlugin(entry[name], name));
				});
			} else {
				compiler.apply(itemToPlugin(entry, "main"));
			}
			return true;
		});
		compiler.apply(new LibManifestPlugin(this.options));
		compiler.apply(new FlagInitialModulesAsUsedPlugin());
	}
}
 
module.exports = DllPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllReferencePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DllReferencePlugin.js

Statements: 13.79% (4 / 29)      Branches: 0% (0 / 14)      Functions: 0% (0 / 3)      Lines: 14.29% (4 / 28)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61            1 1 1                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
const ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
 
class DllReferencePlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
			compilation.dependencyFactories.set(DelegatedSourceDependency, normalModuleFactory);
		});
 
		compiler.plugin("before-compile", (params, callback) => {
			const manifest = this.options.manifest;
			if(typeof manifest === "string") {
				params.compilationDependencies.push(manifest);
				compiler.inputFileSystem.readFile(manifest, function(err, result) {
					if(err) return callback(err);
					params["dll reference " + manifest] = JSON.parse(result.toString("utf-8"));
					return callback();
				});
			} else {
				return callback();
			}
		});
 
		compiler.plugin("compile", (params) => {
			let manifest = this.options.manifest;
			if(typeof manifest === "string") {
				manifest = params["dll reference " + manifest];
			}
			const name = this.options.name || manifest.name;
			const sourceType = this.options.sourceType || "var";
			const externals = {};
			const source = "dll-reference " + name;
			externals[source] = name;
			params.normalModuleFactory.apply(new ExternalModuleFactoryPlugin(sourceType, externals));
			params.normalModuleFactory.apply(new DelegatedModuleFactoryPlugin({
				source: source,
				type: this.options.type,
				scope: this.options.scope,
				context: this.options.context || compiler.options.context,
				content: this.options.content || manifest.content,
				extensions: this.options.extensions
			}));
		});
	}
}
 
module.exports = DllReferencePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DynamicEntryPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/DynamicEntryPlugin.js

Statements: 21.21% (7 / 33)      Branches: 0% (0 / 10)      Functions: 0% (0 / 3)      Lines: 22.58% (7 / 31)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61            1 1 1 1 1                                                                                 1   1              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Naoyuki Kanezawa @nkzawa
*/
"use strict";
 
const MultiEntryDependency = require("./dependencies/MultiEntryDependency");
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
const MultiModuleFactory = require("./MultiModuleFactory");
const MultiEntryPlugin = require("./MultiEntryPlugin");
const SingleEntryPlugin = require("./SingleEntryPlugin");
 
class DynamicEntryPlugin {
	constructor(context, entry) {
		this.context = context;
		this.entry = entry;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const multiModuleFactory = new MultiModuleFactory();
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(MultiEntryDependency, multiModuleFactory);
			compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
		});
 
		compiler.plugin("make", (compilation, callback) => {
			const addEntry = (entry, name) => {
				const dep = DynamicEntryPlugin.createDependency(entry, name);
				return new Promise((resolve, reject) => {
					compilation.addEntry(this.context, dep, name, (err) => {
						if(err) return reject(err);
						resolve();
					});
				});
			};
 
			Promise.resolve(this.entry()).then((entry) => {
				if(typeof entry === "string" || Array.isArray(entry)) {
					addEntry(entry, "main").then(() => callback(), callback);
				} else if(typeof entry === "object") {
					Promise.all(Object.keys(entry).map((name) => {
						return addEntry(entry[name], name);
					})).then(() => callback(), callback);
				}
			});
		});
	}
}
 
module.exports = DynamicEntryPlugin;
 
DynamicEntryPlugin.createDependency = function(entry, name) {
	if(Array.isArray(entry))
		return MultiEntryPlugin.createDependency(entry, name);
	else
		return SingleEntryPlugin.createDependency(entry, name);
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EntryModuleNotFoundError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EntryModuleNotFoundError.js

Statements: 25% (2 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 25% (2 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24            1                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
 
class EntryModuleNotFoundError extends WebpackError {
	constructor(err) {
		super();
 
		this.name = "EntryModuleNotFoundError";
		this.message = "Entry module not found: " + err;
		this.details = err.details;
		this.error = err;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = EntryModuleNotFoundError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EntryOptionPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EntryOptionPlugin.js

Statements: 29.41% (5 / 17)      Branches: 0% (0 / 10)      Functions: 0% (0 / 2)      Lines: 31.25% (5 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            1 1 1   1     1                                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
	*/
"use strict";
 
const SingleEntryPlugin = require("./SingleEntryPlugin");
const MultiEntryPlugin = require("./MultiEntryPlugin");
const DynamicEntryPlugin = require("./DynamicEntryPlugin");
 
module.exports = class EntryOptionPlugin {
	apply(compiler) {
		compiler.plugin("entry-option", (context, entry) => {
			function itemToPlugin(item, name) {
				if(Array.isArray(item)) {
					return new MultiEntryPlugin(context, item, name);
				} else {
					return new SingleEntryPlugin(context, item, name);
				}
			}
			if(typeof entry === "string" || Array.isArray(entry)) {
				compiler.apply(itemToPlugin(entry, "main"));
			} else if(typeof entry === "object") {
				Object.keys(entry).forEach(name => compiler.apply(itemToPlugin(entry[name], name)));
			} else if(typeof entry === "function") {
				compiler.apply(new DynamicEntryPlugin(context, entry));
			}
			return true;
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Entrypoint.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Entrypoint.js

Statements: 6.25% (1 / 16)      Branches: 0% (0 / 4)      Functions: 0% (0 / 4)      Lines: 6.25% (1 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                                    1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class Entrypoint {
	constructor(name) {
		this.name = name;
		this.chunks = [];
	}
 
	unshiftChunk(chunk) {
		this.chunks.unshift(chunk);
		chunk.entrypoints.push(this);
	}
 
	insertChunk(chunk, before) {
		const idx = this.chunks.indexOf(before);
		if(idx >= 0) {
			this.chunks.splice(idx, 0, chunk);
		} else {
			throw new Error("before chunk not found");
		}
		chunk.entrypoints.push(this);
	}
 
	getFiles() {
		const files = [];
 
		for(let chunkIdx = 0; chunkIdx < this.chunks.length; chunkIdx++) {
			for(let fileIdx = 0; fileIdx < this.chunks[chunkIdx].files.length; fileIdx++) {
				if(files.indexOf(this.chunks[chunkIdx].files[fileIdx]) === -1) {
					files.push(this.chunks[chunkIdx].files[fileIdx]);
				}
			}
		}
 
		return files;
	}
}
 
module.exports = Entrypoint;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EnvironmentPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EnvironmentPlugin.js

Statements: 10% (2 / 20)      Branches: 0% (0 / 12)      Functions: 0% (0 / 2)      Lines: 10% (2 / 20)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52              1                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Authors Simen Brekken @simenbrekken, Einar Löve @einarlove
*/
 
"use strict";
 
const DefinePlugin = require("./DefinePlugin");
 
class EnvironmentPlugin {
	constructor(keys) {
		if(Array.isArray(keys)) {
			this.keys = keys;
			this.defaultValues = {};
		} else if(keys && typeof keys === "object") {
			this.keys = Object.keys(keys);
			this.defaultValues = keys;
		} else {
			this.keys = Array.prototype.slice.call(arguments);
			this.defaultValues = {};
		}
	}
 
	apply(compiler) {
		const definitions = this.keys.reduce((defs, key) => {
			const value = process.env[key] !== undefined ? process.env[key] : this.defaultValues[key];
 
			if(value === undefined) {
				compiler.plugin("this-compilation", compilation => {
					const error = new Error(
						`EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
						"You can pass an object with default values to suppress this warning.\n" +
						"See https://webpack.js.org/plugins/environment-plugin for example."
					);
 
					error.name = "EnvVariableNotDefinedError";
					compilation.warnings.push(error);
				});
			}
 
			defs[`process.env.${key}`] = typeof value === "undefined" ? "undefined" : JSON.stringify(value);
 
			return defs;
		}, {});
 
		compiler.apply(new DefinePlugin(definitions));
	}
}
 
module.exports = EnvironmentPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ErrorHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ErrorHelpers.js

Statements: 23.53% (4 / 17)      Branches: 0% (0 / 8)      Functions: 100% (0 / 0)      Lines: 23.53% (4 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            1   1               1                   1            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const loaderFlag = "LOADER_EXECUTION";
 
exports.cutOffLoaderExecution = (stack) => {
	stack = stack.split("\n");
	for(let i = 0; i < stack.length; i++)
		if(stack[i].indexOf(loaderFlag) >= 0)
			stack.length = i;
	return stack.join("\n");
};
 
exports.cutOffMessage = (stack, message) => {
	const nextLine = stack.indexOf("\n");
	if(nextLine === -1) {
		return stack === message ? "" : stack;
	} else {
		const firstLine = stack.substr(0, nextLine);
		return firstLine === message ? stack.substr(nextLine + 1) : stack;
	}
};
 
exports.cleanUp = (stack, message) => {
	stack = exports.cutOffLoaderExecution(stack);
	stack = exports.cutOffMessage(stack, message);
	return stack;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalDevToolModulePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalDevToolModulePlugin.js

Statements: 33.33% (2 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24            1                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const EvalDevToolModuleTemplatePlugin = require("./EvalDevToolModuleTemplatePlugin");
 
class EvalDevToolModulePlugin {
	constructor(sourceUrlComment, moduleFilenameTemplate) {
		this.sourceUrlComment = sourceUrlComment;
		this.moduleFilenameTemplate = moduleFilenameTemplate;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.moduleTemplate.apply(new EvalDevToolModuleTemplatePlugin(this.sourceUrlComment, this.moduleFilenameTemplate));
		});
	}
}
 
module.exports = EvalDevToolModulePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalDevToolModuleTemplatePlugin.js

Statements: 23.08% (3 / 13)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 23.08% (3 / 13)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » EvalDevToolModuleTemplatePlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35            1 1                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RawSource = require("webpack-sources").RawSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
 
class EvalDevToolModuleTemplatePlugin {
	constructor(sourceUrlComment, moduleFilenameTemplate) {
		this.sourceUrlComment = sourceUrlComment || "\n//# sourceURL=[url]";
		this.moduleFilenameTemplate = moduleFilenameTemplate || "webpack:///[resourcePath]?[loaders]";
	}
 
	apply(moduleTemplate) {
		moduleTemplate.plugin("module", (source, module) => {
			const content = source.source();
			const str = ModuleFilenameHelpers.createFilename(module, this.moduleFilenameTemplate, moduleTemplate.requestShortener);
			const footer = ["\n",
				ModuleFilenameHelpers.createFooter(module, moduleTemplate.requestShortener),
				this.sourceUrlComment.replace(/\[url\]/g, encodeURI(str).replace(/%2F/g, "/").replace(/%20/g, "_").replace(/%5E/g, "^").replace(/%5C/g, "\\").replace(/^\//, ""))
			].join("\n");
			return new RawSource(`eval(${JSON.stringify(content + footer)});`);
		});
		moduleTemplate.plugin("hash", hash => {
			hash.update("EvalDevToolModuleTemplatePlugin");
			hash.update("2");
		});
	}
}
 
module.exports = EvalDevToolModuleTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalSourceMapDevToolModuleTemplatePlugin.js

Statements: 6.52% (3 / 46)      Branches: 0% (0 / 16)      Functions: 0% (0 / 9)      Lines: 6.52% (3 / 46)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » EvalSourceMapDevToolModuleTemplatePlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76            1 1                                                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RawSource = require("webpack-sources").RawSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
 
class EvalSourceMapDevToolModuleTemplatePlugin {
	constructor(compilation, options) {
		this.compilation = compilation;
		this.sourceMapComment = options.append || "//# sourceMappingURL=[url]";
		this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resource-path]?[hash]";
		this.options = options;
	}
 
	apply(moduleTemplate) {
		const self = this;
		const options = this.options;
		moduleTemplate.plugin("module", function(source, module) {
			if(source.__EvalSourceMapDevToolData)
				return source.__EvalSourceMapDevToolData;
			let sourceMap;
			let content;
			if(source.sourceAndMap) {
				const sourceAndMap = source.sourceAndMap(options);
				sourceMap = sourceAndMap.map;
				content = sourceAndMap.source;
			} else {
				sourceMap = source.map(options);
				content = source.source();
			}
			if(!sourceMap) {
				return source;
			}
 
			// Clone (flat) the sourcemap to ensure that the mutations below do not persist.
			sourceMap = Object.keys(sourceMap).reduce(function(obj, key) {
				obj[key] = sourceMap[key];
				return obj;
			}, {});
			const modules = sourceMap.sources.map(function(source) {
				const module = self.compilation.findModule(source);
				return module || source;
			});
			let moduleFilenames = modules.map(function(module) {
				return ModuleFilenameHelpers.createFilename(module, self.moduleFilenameTemplate, this.requestShortener);
			}, this);
			moduleFilenames = ModuleFilenameHelpers.replaceDuplicates(moduleFilenames, function(filename, i, n) {
				for(let j = 0; j < n; j++)
					filename += "*";
				return filename;
			});
			sourceMap.sources = moduleFilenames;
			if(sourceMap.sourcesContent) {
				sourceMap.sourcesContent = sourceMap.sourcesContent.map(function(content, i) {
					return `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], this.requestShortener)}`;
				}, this);
			}
			sourceMap.sourceRoot = options.sourceRoot || "";
			sourceMap.file = `${module.id}.js`;
 
			const footer = self.sourceMapComment.replace(/\[url\]/g, `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf8").toString("base64")}`); //eslint-disable-line
			source.__EvalSourceMapDevToolData = new RawSource(`eval(${JSON.stringify(content + footer)});`);
			return source.__EvalSourceMapDevToolData;
		});
		moduleTemplate.plugin("hash", function(hash) {
			hash.update("eval-source-map");
			hash.update("1");
		});
	}
}
module.exports = EvalSourceMapDevToolModuleTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalSourceMapDevToolPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/EvalSourceMapDevToolPlugin.js

Statements: 21.43% (3 / 14)      Branches: 0% (0 / 6)      Functions: 0% (0 / 2)      Lines: 23.08% (3 / 13)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » EvalSourceMapDevToolPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34            1 1                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const EvalSourceMapDevToolModuleTemplatePlugin = require("./EvalSourceMapDevToolModuleTemplatePlugin");
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
 
class EvalSourceMapDevToolPlugin {
	constructor(options) {
		if(arguments.length > 1)
			throw new Error("EvalSourceMapDevToolPlugin only takes one argument (pass an options object)");
		if(typeof options === "string") {
			options = {
				append: options
			};
		}
		if(!options) options = {};
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation) => {
			new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
			compilation.moduleTemplate.apply(new EvalSourceMapDevToolModuleTemplatePlugin(compilation, options));
		});
	}
}
 
module.exports = EvalSourceMapDevToolPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExtendedAPIPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExtendedAPIPlugin.js

Statements: 25% (6 / 24)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 26.09% (6 / 23)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49            1 1 1   1       1                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConstDependency = require("./dependencies/ConstDependency");
const ParserHelpers = require("./ParserHelpers");
const NullFactory = require("./NullFactory");
 
const REPLACEMENTS = {
	__webpack_hash__: "__webpack_require__.h", // eslint-disable-line camelcase
	__webpack_chunkname__: "__webpack_require__.cn" // eslint-disable-line camelcase
};
const REPLACEMENT_TYPES = {
	__webpack_hash__: "string", // eslint-disable-line camelcase
	__webpack_chunkname__: "string" // eslint-disable-line camelcase
};
 
class ExtendedAPIPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
			compilation.mainTemplate.plugin("require-extensions", function(source, chunk, hash) {
				const buf = [source];
				buf.push("");
				buf.push("// __webpack_hash__");
				buf.push(`${this.requireFn}.h = ${JSON.stringify(hash)};`);
				buf.push("");
				buf.push("// __webpack_chunkname__");
				buf.push(`${this.requireFn}.cn = ${JSON.stringify(chunk.name)};`);
				return this.asString(buf);
			});
			compilation.mainTemplate.plugin("global-hash", () => true);
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
				Object.keys(REPLACEMENTS).forEach(key => {
					parser.plugin(`expression ${key}`, ParserHelpers.toConstantDependency(REPLACEMENTS[key]));
					parser.plugin(`evaluate typeof ${key}`, ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key]));
				});
			});
		});
	}
}
 
module.exports = ExtendedAPIPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExternalModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExternalModule.js

Statements: 13.33% (6 / 45)      Branches: 0% (0 / 21)      Functions: 0% (0 / 15)      Lines: 13.95% (6 / 43)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118          1 1 1 1 1                                                                                                                                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Module = require("./Module");
const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
const WebpackMissingModule = require("./dependencies/WebpackMissingModule");
const Template = require("./Template");
 
class ExternalModule extends Module {
	constructor(request, type) {
		super();
		this.request = request;
		this.type = type;
		this.built = false;
		this.external = true;
	}
 
	chunkCondition(chunk) {
		return chunk.hasEntryModule();
	}
 
	identifier() {
		return "external " + JSON.stringify(this.request);
	}
 
	readableIdentifier() {
		return "external " + JSON.stringify(this.request);
	}
 
	needRebuild() {
		return false;
	}
 
	build(options, compilation, resolver, fs, callback) {
		this.builtTime = new Date().getTime();
		callback();
	}
 
	getSourceForGlobalVariableExternal(variableName, type) {
		if(!Array.isArray(variableName)) {
			// make it an array as the look up works the same basically
			variableName = [variableName];
		}
 
		// needed for e.g. window["some"]["thing"]
		const objectLookup = variableName.map(r => `[${JSON.stringify(r)}]`).join("");
		return `(function() { module.exports = ${type}${objectLookup}; }());`;
	}
 
	getSourceForCommonJsExternal(moduleAndSpecifiers) {
		if(!Array.isArray(moduleAndSpecifiers)) {
			return `module.exports = require(${JSON.stringify(moduleAndSpecifiers)});`;
		}
 
		const moduleName = moduleAndSpecifiers[0];
		const objectLookup = moduleAndSpecifiers.slice(1).map(r => `[${JSON.stringify(r)}]`).join("");
		return `module.exports = require(${moduleName})${objectLookup};`;
	}
 
	checkExternalVariable(variableToCheck, request) {
		return `if(typeof ${variableToCheck} === 'undefined') {${WebpackMissingModule.moduleCode(request)}}\n`;
	}
 
	getSourceForAmdOrUmdExternal(id, optional, request) {
		const externalVariable = Template.toIdentifier(`__WEBPACK_EXTERNAL_MODULE_${id}__`);
		const missingModuleError = optional ? this.checkExternalVariable(externalVariable, request) : "";
		return `${missingModuleError}module.exports = ${externalVariable};`;
	}
 
	getSourceForDefaultCase(optional, request) {
		const missingModuleError = optional ? this.checkExternalVariable(request, request) : "";
		return `${missingModuleError}module.exports = ${request};`;
	}
 
	getSourceString() {
		const request = typeof this.request === "object" ? this.request[this.type] : this.request;
		switch(this.type) {
			case "this":
			case "window":
			case "global":
				return this.getSourceForGlobalVariableExternal(request, this.type);
			case "commonjs":
			case "commonjs2":
				return this.getSourceForCommonJsExternal(request);
			case "amd":
			case "umd":
			case "umd2":
				return this.getSourceForAmdOrUmdExternal(this.id, this.optional, request);
			default:
				return this.getSourceForDefaultCase(this.optional, request);
		}
	}
 
	getSource(sourceString) {
		if(this.useSourceMap) {
			return new OriginalSource(sourceString, this.identifier());
		}
 
		return new RawSource(sourceString);
	}
 
	source() {
		return this.getSource(
			this.getSourceString()
		);
	}
 
	size() {
		return 42;
	}
}
 
module.exports = ExternalModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExternalModuleFactoryPlugin.js

Statements: 4.55% (3 / 66)      Branches: 0% (0 / 44)      Functions: 0% (0 / 8)      Lines: 5.17% (3 / 58)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » ExternalModuleFactoryPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93            1                           1                                                                                                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ExternalModule = require("./ExternalModule");
 
class ExternalModuleFactoryPlugin {
	constructor(type, externals) {
		this.type = type;
		this.externals = externals;
	}
 
	apply(normalModuleFactory) {
		const globalType = this.type;
		normalModuleFactory.plugin("factory", factory => (data, callback) => {
			const context = data.context;
			const dependency = data.dependencies[0];
 
			function handleExternal(value, type, callback) {
				if(typeof type === "function") {
					callback = type;
					type = undefined;
				}
				if(value === false) return factory(data, callback);
				if(value === true) value = dependency.request;
				if(typeof type === "undefined" && /^[a-z0-9]+ /.test(value)) {
					const idx = value.indexOf(" ");
					type = value.substr(0, idx);
					value = value.substr(idx + 1);
				}
				callback(null, new ExternalModule(value, type || globalType));
				return true;
			}
			(function handleExternals(externals, callback) {
				if(typeof externals === "string") {
					if(externals === dependency.request) {
						return handleExternal(dependency.request, callback);
					}
				} else if(Array.isArray(externals)) {
					let i = 0;
					(function next() {
						let asyncFlag;
						const handleExternalsAndCallback = function handleExternalsAndCallback(err, module) {
							if(err) return callback(err);
							if(!module) {
								if(asyncFlag) {
									asyncFlag = false;
									return;
								}
								return next();
							}
							callback(null, module);
						};
 
						do {
							asyncFlag = true;
							if(i >= externals.length) return callback();
							handleExternals(externals[i++], handleExternalsAndCallback);
						} while (!asyncFlag); // eslint-disable-line keyword-spacing
						asyncFlag = false;
					}());
					return;
				} else if(externals instanceof RegExp) {
					if(externals.test(dependency.request)) {
						return handleExternal(dependency.request, callback);
					}
				} else if(typeof externals === "function") {
					externals.call(null, context, dependency.request, function(err, value, type) {
						if(err) return callback(err);
						if(typeof value !== "undefined") {
							handleExternal(value, type, callback);
						} else {
							callback();
						}
					});
					return;
				} else if(typeof externals === "object" && Object.prototype.hasOwnProperty.call(externals, dependency.request)) {
					return handleExternal(externals[dependency.request], callback);
				}
				callback();
			}(this.externals, function(err, module) {
				if(err) return callback(err);
				if(!module) return handleExternal(false, callback);
				return callback(null, module);
			}));
		});
	}
}
module.exports = ExternalModuleFactoryPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExternalsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ExternalsPlugin.js

Statements: 33.33% (2 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23            1                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
var ExternalModuleFactoryPlugin = require("./ExternalModuleFactoryPlugin");
 
class ExternalsPlugin {
	constructor(type, externals) {
		this.type = type;
		this.externals = externals;
	}
	apply(compiler) {
		compiler.plugin("compile", (params) => {
			params.normalModuleFactory.apply(new ExternalModuleFactoryPlugin(this.type, this.externals));
		});
	}
}
 
module.exports = ExternalsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FlagDependencyExportsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FlagDependencyExportsPlugin.js

Statements: 7.81% (5 / 64)      Branches: 0% (0 / 30)      Functions: 0% (0 / 5)      Lines: 8.47% (5 / 59)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » FlagDependencyExportsPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103                                                                  1               1                                                                         1               1                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class FlagDependencyExportsPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("finish-modules", (modules) => {
				const dependencies = Object.create(null);
 
				let module;
				let moduleWithExports;
				let moduleProvidedExports;
				const queue = modules.filter((m) => !m.providedExports);
				for(let i = 0; i < queue.length; i++) {
					module = queue[i];
 
					if(module.providedExports !== true) {
						moduleWithExports = false;
						moduleProvidedExports = Array.isArray(module.providedExports) ? new Set(module.providedExports) : new Set();
						processDependenciesBlock(module);
						if(!moduleWithExports) {
							module.providedExports = true;
							notifyDependencies();
						} else if(module.providedExports !== true) {
							module.providedExports = Array.from(moduleProvidedExports);
						}
					}
				}
 
				function processDependenciesBlock(depBlock) {
					depBlock.dependencies.forEach((dep) => processDependency(dep));
					depBlock.variables.forEach((variable) => {
						variable.dependencies.forEach((dep) => processDependency(dep));
					});
					depBlock.blocks.forEach(processDependenciesBlock);
				}
 
				function processDependency(dep) {
					const exportDesc = dep.getExports && dep.getExports();
					if(!exportDesc) return;
					moduleWithExports = true;
					const exports = exportDesc.exports;
					const exportDeps = exportDesc.dependencies;
					if(exportDeps) {
						exportDeps.forEach((dep) => {
							const depIdent = dep.identifier();
							// if this was not yet initialized
							// initialize it as an array containing the module and stop
							const array = dependencies[depIdent];
							if(!array) {
								dependencies[depIdent] = [module];
								return;
							}
 
							// check if this module is known
							// if not, add it to the dependencies for this identifier
							if(array.indexOf(module) < 0)
								array.push(module);
						});
					}
					let changed = false;
					if(module.providedExports !== true) {
						if(exports === true) {
							module.providedExports = true;
							changed = true;
						} else if(Array.isArray(exports)) {
							changed = addToSet(moduleProvidedExports, exports);
						}
					}
					if(changed) {
						notifyDependencies();
					}
				}
 
				function notifyDependencies() {
					const deps = dependencies[module.identifier()];
					if(deps) {
						deps.forEach((dep) => queue.push(dep));
					}
				}
			});
 
			function addToSet(a, b) {
				let changed = false;
				b.forEach((item) => {
					if(!a.has(item)) {
						a.add(item);
						changed = true;
					}
				});
				return changed;
			}
		});
	}
}
 
module.exports = FlagDependencyExportsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FlagDependencyUsagePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FlagDependencyUsagePlugin.js

Statements: 10.53% (6 / 57)      Branches: 0% (0 / 32)      Functions: 0% (0 / 6)      Lines: 12.5% (6 / 48)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83                                                  1                                     1           1                           1               1               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class FlagDependencyUsagePlugin {
	apply(compiler) {
		compiler.plugin("compilation", compilation => {
			compilation.plugin("optimize-modules-advanced", modules => {
 
				modules.forEach(module => module.used = false);
 
				const queue = [];
				compilation.chunks.forEach(chunk => {
					if(chunk.entryModule) {
						processModule(chunk.entryModule, true);
					}
				});
 
				while(queue.length) {
					const queueItem = queue.pop();
					processDependenciesBlock(queueItem[0], queueItem[1]);
				}
 
				function processModule(module, usedExports) {
					module.used = true;
					if(module.usedExports === true)
						return;
					else if(usedExports === true)
						module.usedExports = true;
					else if(Array.isArray(usedExports)) {
						var old = module.usedExports ? module.usedExports.length : -1;
						module.usedExports = addToSet(module.usedExports || [], usedExports);
						if(module.usedExports.length === old)
							return;
					} else if(Array.isArray(module.usedExports))
						return;
					else
						module.usedExports = false;
 
					queue.push([module, module.usedExports]);
				}
 
				function processDependenciesBlock(depBlock, usedExports) {
					depBlock.dependencies.forEach(dep => processDependency(dep));
					depBlock.variables.forEach(variable => variable.dependencies.forEach(dep => processDependency(dep)));
					depBlock.blocks.forEach(block => queue.push([block, usedExports]));
				}
 
				function processDependency(dep) {
					const reference = dep.getReference && dep.getReference();
					if(!reference) return;
					const module = reference.module;
					const importedNames = reference.importedNames;
					const oldUsed = module.used;
					const oldUsedExports = module.usedExports;
					if(!oldUsed || (importedNames && (!oldUsedExports || !isSubset(oldUsedExports, importedNames)))) {
						processModule(module, importedNames);
					}
				}
 
			});
 
			function addToSet(a, b) {
				b.forEach(item => {
					if(a.indexOf(item) < 0)
						a.push(item);
				});
				return a;
			}
 
			function isSubset(biggerSet, subset) {
				if(biggerSet === true) return true;
				if(subset === true) return false;
				return subset.every(item => biggerSet.indexOf(item) >= 0);
			}
		});
	}
}
module.exports = FlagDependencyUsagePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FlagInitialModulesAsUsedPlugin.js

Statements: 12.5% (1 / 8)      Branches: 0% (0 / 2)      Functions: 0% (0 / 1)      Lines: 12.5% (1 / 8)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » FlagInitialModulesAsUsedPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26                                              1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class FlagInitialModulesAsUsedPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("after-optimize-chunks", (chunks) => {
				chunks.forEach((chunk) => {
					if(!chunk.isInitial()) {
						return;
					}
					chunk.modules.forEach((module) => {
						module.usedExports = true;
					});
				});
			});
		});
	}
}
 
module.exports = FlagInitialModulesAsUsedPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FunctionModulePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FunctionModulePlugin.js

Statements: 37.5% (3 / 8)      Branches: 0% (0 / 2)      Functions: 0% (0 / 2)      Lines: 37.5% (3 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            1 1                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const FunctionModuleTemplatePlugin = require("./FunctionModuleTemplatePlugin");
const RequestShortener = require("./RequestShortener");
 
class FunctionModulePlugin {
	constructor(options, requestShortener) {
		this.options = options;
		this.requestShortener = requestShortener;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.moduleTemplate.requestShortener = this.requestShortener || new RequestShortener(compiler.context);
			compilation.moduleTemplate.apply(new FunctionModuleTemplatePlugin());
		});
	}
}
 
module.exports = FunctionModulePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FunctionModuleTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/FunctionModuleTemplatePlugin.js

Statements: 5.71% (2 / 35)      Branches: 0% (0 / 23)      Functions: 0% (0 / 4)      Lines: 6.06% (2 / 33)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » FunctionModuleTemplatePlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53            1                                                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
 
class FunctionModuleTemplatePlugin {
	apply(moduleTemplate) {
		moduleTemplate.plugin("render", function(moduleSource, module) {
			const source = new ConcatSource();
			const defaultArguments = [module.moduleArgument || "module", module.exportsArgument || "exports"];
			if((module.arguments && module.arguments.length !== 0) || module.hasDependencies(d => d.requireWebpackRequire !== false)) {
				defaultArguments.push("__webpack_require__");
			}
			source.add("/***/ (function(" + defaultArguments.concat(module.arguments || []).join(", ") + ") {\n\n");
			if(module.strict) source.add("\"use strict\";\n");
			source.add(moduleSource);
			source.add("\n\n/***/ })");
			return source;
		});
 
		moduleTemplate.plugin("package", function(moduleSource, module) {
			if(this.outputOptions.pathinfo) {
				const source = new ConcatSource();
				const req = module.readableIdentifier(this.requestShortener);
				if(Array.isArray(module.providedExports))
					source.add("/* exports provided: " + module.providedExports.join(", ") + " */\n");
				else if(module.providedExports)
					source.add("/* unknown exports provided */\n");
				if(Array.isArray(module.usedExports))
					source.add("/* exports used: " + module.usedExports.join(", ") + " */\n");
				else if(module.usedExports)
					source.add("/* all exports used */\n");
				source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
				source.add("  !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
				source.add("  \\****" + req.replace(/./g, "*") + "****/\n");
				source.add(moduleSource);
				return source;
			}
			return moduleSource;
		});
 
		moduleTemplate.plugin("hash", function(hash) {
			hash.update("FunctionModuleTemplatePlugin");
			hash.update("2");
		});
	}
}
module.exports = FunctionModuleTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HashedModuleIdsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HashedModuleIdsPlugin.js

Statements: 11.11% (2 / 18)      Branches: 0% (0 / 6)      Functions: 0% (0 / 2)      Lines: 11.11% (2 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44          1                                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const createHash = require("crypto").createHash;
 
class HashedModuleIdsPlugin {
	constructor(options) {
		this.options = Object.assign({
			hashFunction: "md5",
			hashDigest: "base64",
			hashDigestLength: 4
		}, options);
	}
 
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation) => {
			const usedIds = new Set();
			compilation.plugin("before-module-ids", (modules) => {
				modules.forEach((module) => {
					if(module.id === null && module.libIdent) {
						const id = module.libIdent({
							context: this.options.context || compiler.options.context
						});
						const hash = createHash(options.hashFunction);
						hash.update(id);
						const hashId = hash.digest(options.hashDigest);
						let len = options.hashDigestLength;
						while(usedIds.has(hashId.substr(0, len)))
							len++;
						module.id = hashId.substr(0, len);
						usedIds.add(module.id);
					}
				});
			});
		});
	}
}
 
module.exports = HashedModuleIdsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HotModuleReplacement.runtime.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HotModuleReplacement.runtime.js

Statements: 3.8% (13 / 342)      Branches: 0% (0 / 183)      Functions: 0% (0 / 36)      Lines: 3.95% (13 / 329)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » HotModuleReplacement.runtime.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585          1                 1                                                                                           1                             1                                                                                                                                       1                                 1         1                                                                   1                           1                   1                                           1                   1                                                                                                                                     1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*global $hash$ installedModules $require$ hotDownloadManifest hotDownloadUpdateChunk hotDisposeChunk modules */
module.exports = function() {
 
	var hotApplyOnUpdate = true;
	var hotCurrentHash = $hash$; // eslint-disable-line no-unused-vars
	var hotCurrentModuleData = {};
	var hotCurrentChildModule; // eslint-disable-line no-unused-vars
	var hotCurrentParents = []; // eslint-disable-line no-unused-vars
	var hotCurrentParentsTemp = []; // eslint-disable-line no-unused-vars
 
	function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars
		var me = installedModules[moduleId];
		if(!me) return $require$;
		var fn = function(request) {
			if(me.hot.active) {
				if(installedModules[request]) {
					if(installedModules[request].parents.indexOf(moduleId) < 0)
						installedModules[request].parents.push(moduleId);
				} else {
					hotCurrentParents = [moduleId];
					hotCurrentChildModule = request;
				}
				if(me.children.indexOf(request) < 0)
					me.children.push(request);
			} else {
				console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId);
				hotCurrentParents = [];
			}
			return $require$(request);
		};
		var ObjectFactory = function ObjectFactory(name) {
			return {
				configurable: true,
				enumerable: true,
				get: function() {
					return $require$[name];
				},
				set: function(value) {
					$require$[name] = value;
				}
			};
		};
		for(var name in $require$) {
			if(Object.prototype.hasOwnProperty.call($require$, name) && name !== "e") {
				Object.defineProperty(fn, name, ObjectFactory(name));
			}
		}
		fn.e = function(chunkId) {
			if(hotStatus === "ready")
				hotSetStatus("prepare");
			hotChunksLoading++;
			return $require$.e(chunkId).then(finishChunkLoading, function(err) {
				finishChunkLoading();
				throw err;
			});
 
			function finishChunkLoading() {
				hotChunksLoading--;
				if(hotStatus === "prepare") {
					if(!hotWaitingFilesMap[chunkId]) {
						hotEnsureUpdateChunk(chunkId);
					}
					if(hotChunksLoading === 0 && hotWaitingFiles === 0) {
						hotUpdateDownloaded();
					}
				}
			}
		};
		return fn;
	}
 
	function hotCreateModule(moduleId) { // eslint-disable-line no-unused-vars
		var hot = {
			// private stuff
			_acceptedDependencies: {},
			_declinedDependencies: {},
			_selfAccepted: false,
			_selfDeclined: false,
			_disposeHandlers: [],
			_main: hotCurrentChildModule !== moduleId,
 
			// Module API
			active: true,
			accept: function(dep, callback) {
				if(typeof dep === "undefined")
					hot._selfAccepted = true;
				else if(typeof dep === "function")
					hot._selfAccepted = dep;
				else if(typeof dep === "object")
					for(var i = 0; i < dep.length; i++)
						hot._acceptedDependencies[dep[i]] = callback || function() {};
				else
					hot._acceptedDependencies[dep] = callback || function() {};
			},
			decline: function(dep) {
				if(typeof dep === "undefined")
					hot._selfDeclined = true;
				else if(typeof dep === "object")
					for(var i = 0; i < dep.length; i++)
						hot._declinedDependencies[dep[i]] = true;
				else
					hot._declinedDependencies[dep] = true;
			},
			dispose: function(callback) {
				hot._disposeHandlers.push(callback);
			},
			addDisposeHandler: function(callback) {
				hot._disposeHandlers.push(callback);
			},
			removeDisposeHandler: function(callback) {
				var idx = hot._disposeHandlers.indexOf(callback);
				if(idx >= 0) hot._disposeHandlers.splice(idx, 1);
			},
 
			// Management API
			check: hotCheck,
			apply: hotApply,
			status: function(l) {
				if(!l) return hotStatus;
				hotStatusHandlers.push(l);
			},
			addStatusHandler: function(l) {
				hotStatusHandlers.push(l);
			},
			removeStatusHandler: function(l) {
				var idx = hotStatusHandlers.indexOf(l);
				if(idx >= 0) hotStatusHandlers.splice(idx, 1);
			},
 
			//inherit from previous dispose call
			data: hotCurrentModuleData[moduleId]
		};
		hotCurrentChildModule = undefined;
		return hot;
	}
 
	var hotStatusHandlers = [];
	var hotStatus = "idle";
 
	function hotSetStatus(newStatus) {
		hotStatus = newStatus;
		for(var i = 0; i < hotStatusHandlers.length; i++)
			hotStatusHandlers[i].call(null, newStatus);
	}
 
	// while downloading
	var hotWaitingFiles = 0;
	var hotChunksLoading = 0;
	var hotWaitingFilesMap = {};
	var hotRequestedFilesMap = {};
	var hotAvailableFilesMap = {};
	var hotDeferred;
 
	// The update info
	var hotUpdate, hotUpdateNewHash;
 
	function toModuleId(id) {
		var isNumber = (+id) + "" === id;
		return isNumber ? +id : id;
	}
 
	function hotCheck(apply) {
		if(hotStatus !== "idle") throw new Error("check() is only allowed in idle status");
		hotApplyOnUpdate = apply;
		hotSetStatus("check");
		return hotDownloadManifest().then(function(update) {
			if(!update) {
				hotSetStatus("idle");
				return null;
			}
			hotRequestedFilesMap = {};
			hotWaitingFilesMap = {};
			hotAvailableFilesMap = update.c;
			hotUpdateNewHash = update.h;
 
			hotSetStatus("prepare");
			var promise = new Promise(function(resolve, reject) {
				hotDeferred = {
					resolve: resolve,
					reject: reject
				};
			});
			hotUpdate = {};
			/*foreachInstalledChunks*/
			{ // eslint-disable-line no-lone-blocks
				/*globals chunkId */
				hotEnsureUpdateChunk(chunkId);
			}
			if(hotStatus === "prepare" && hotChunksLoading === 0 && hotWaitingFiles === 0) {
				hotUpdateDownloaded();
			}
			return promise;
		});
	}
 
	function hotAddUpdateChunk(chunkId, moreModules) { // eslint-disable-line no-unused-vars
		if(!hotAvailableFilesMap[chunkId] || !hotRequestedFilesMap[chunkId])
			return;
		hotRequestedFilesMap[chunkId] = false;
		for(var moduleId in moreModules) {
			if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
				hotUpdate[moduleId] = moreModules[moduleId];
			}
		}
		if(--hotWaitingFiles === 0 && hotChunksLoading === 0) {
			hotUpdateDownloaded();
		}
	}
 
	function hotEnsureUpdateChunk(chunkId) {
		if(!hotAvailableFilesMap[chunkId]) {
			hotWaitingFilesMap[chunkId] = true;
		} else {
			hotRequestedFilesMap[chunkId] = true;
			hotWaitingFiles++;
			hotDownloadUpdateChunk(chunkId);
		}
	}
 
	function hotUpdateDownloaded() {
		hotSetStatus("ready");
		var deferred = hotDeferred;
		hotDeferred = null;
		if(!deferred) return;
		if(hotApplyOnUpdate) {
			hotApply(hotApplyOnUpdate).then(function(result) {
				deferred.resolve(result);
			}, function(err) {
				deferred.reject(err);
			});
		} else {
			var outdatedModules = [];
			for(var id in hotUpdate) {
				if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
					outdatedModules.push(toModuleId(id));
				}
			}
			deferred.resolve(outdatedModules);
		}
	}
 
	function hotApply(options) {
		if(hotStatus !== "ready") throw new Error("apply() is only allowed in ready status");
		options = options || {};
 
		var cb;
		var i;
		var j;
		var module;
		var moduleId;
 
		function getAffectedStuff(updateModuleId) {
			var outdatedModules = [updateModuleId];
			var outdatedDependencies = {};
 
			var queue = outdatedModules.slice().map(function(id) {
				return {
					chain: [id],
					id: id
				};
			});
			while(queue.length > 0) {
				var queueItem = queue.pop();
				var moduleId = queueItem.id;
				var chain = queueItem.chain;
				module = installedModules[moduleId];
				if(!module || module.hot._selfAccepted)
					continue;
				if(module.hot._selfDeclined) {
					return {
						type: "self-declined",
						chain: chain,
						moduleId: moduleId
					};
				}
				if(module.hot._main) {
					return {
						type: "unaccepted",
						chain: chain,
						moduleId: moduleId
					};
				}
				for(var i = 0; i < module.parents.length; i++) {
					var parentId = module.parents[i];
					var parent = installedModules[parentId];
					if(!parent) continue;
					if(parent.hot._declinedDependencies[moduleId]) {
						return {
							type: "declined",
							chain: chain.concat([parentId]),
							moduleId: moduleId,
							parentId: parentId
						};
					}
					if(outdatedModules.indexOf(parentId) >= 0) continue;
					if(parent.hot._acceptedDependencies[moduleId]) {
						if(!outdatedDependencies[parentId])
							outdatedDependencies[parentId] = [];
						addAllToSet(outdatedDependencies[parentId], [moduleId]);
						continue;
					}
					delete outdatedDependencies[parentId];
					outdatedModules.push(parentId);
					queue.push({
						chain: chain.concat([parentId]),
						id: parentId
					});
				}
			}
 
			return {
				type: "accepted",
				moduleId: updateModuleId,
				outdatedModules: outdatedModules,
				outdatedDependencies: outdatedDependencies
			};
		}
 
		function addAllToSet(a, b) {
			for(var i = 0; i < b.length; i++) {
				var item = b[i];
				if(a.indexOf(item) < 0)
					a.push(item);
			}
		}
 
		// at begin all updates modules are outdated
		// the "outdated" status can propagate to parents if they don't accept the children
		var outdatedDependencies = {};
		var outdatedModules = [];
		var appliedUpdate = {};
 
		var warnUnexpectedRequire = function warnUnexpectedRequire() {
			console.warn("[HMR] unexpected require(" + result.moduleId + ") to disposed module");
		};
 
		for(var id in hotUpdate) {
			if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) {
				moduleId = toModuleId(id);
				var result;
				if(hotUpdate[id]) {
					result = getAffectedStuff(moduleId);
				} else {
					result = {
						type: "disposed",
						moduleId: id
					};
				}
				var abortError = false;
				var doApply = false;
				var doDispose = false;
				var chainInfo = "";
				if(result.chain) {
					chainInfo = "\nUpdate propagation: " + result.chain.join(" -> ");
				}
				switch(result.type) {
					case "self-declined":
						if(options.onDeclined)
							options.onDeclined(result);
						if(!options.ignoreDeclined)
							abortError = new Error("Aborted because of self decline: " + result.moduleId + chainInfo);
						break;
					case "declined":
						if(options.onDeclined)
							options.onDeclined(result);
						if(!options.ignoreDeclined)
							abortError = new Error("Aborted because of declined dependency: " + result.moduleId + " in " + result.parentId + chainInfo);
						break;
					case "unaccepted":
						if(options.onUnaccepted)
							options.onUnaccepted(result);
						if(!options.ignoreUnaccepted)
							abortError = new Error("Aborted because " + moduleId + " is not accepted" + chainInfo);
						break;
					case "accepted":
						if(options.onAccepted)
							options.onAccepted(result);
						doApply = true;
						break;
					case "disposed":
						if(options.onDisposed)
							options.onDisposed(result);
						doDispose = true;
						break;
					default:
						throw new Error("Unexception type " + result.type);
				}
				if(abortError) {
					hotSetStatus("abort");
					return Promise.reject(abortError);
				}
				if(doApply) {
					appliedUpdate[moduleId] = hotUpdate[moduleId];
					addAllToSet(outdatedModules, result.outdatedModules);
					for(moduleId in result.outdatedDependencies) {
						if(Object.prototype.hasOwnProperty.call(result.outdatedDependencies, moduleId)) {
							if(!outdatedDependencies[moduleId])
								outdatedDependencies[moduleId] = [];
							addAllToSet(outdatedDependencies[moduleId], result.outdatedDependencies[moduleId]);
						}
					}
				}
				if(doDispose) {
					addAllToSet(outdatedModules, [result.moduleId]);
					appliedUpdate[moduleId] = warnUnexpectedRequire;
				}
			}
		}
 
		// Store self accepted outdated modules to require them later by the module system
		var outdatedSelfAcceptedModules = [];
		for(i = 0; i < outdatedModules.length; i++) {
			moduleId = outdatedModules[i];
			if(installedModules[moduleId] && installedModules[moduleId].hot._selfAccepted)
				outdatedSelfAcceptedModules.push({
					module: moduleId,
					errorHandler: installedModules[moduleId].hot._selfAccepted
				});
		}
 
		// Now in "dispose" phase
		hotSetStatus("dispose");
		Object.keys(hotAvailableFilesMap).forEach(function(chunkId) {
			if(hotAvailableFilesMap[chunkId] === false) {
				hotDisposeChunk(chunkId);
			}
		});
 
		var idx;
		var queue = outdatedModules.slice();
		while(queue.length > 0) {
			moduleId = queue.pop();
			module = installedModules[moduleId];
			if(!module) continue;
 
			var data = {};
 
			// Call dispose handlers
			var disposeHandlers = module.hot._disposeHandlers;
			for(j = 0; j < disposeHandlers.length; j++) {
				cb = disposeHandlers[j];
				cb(data);
			}
			hotCurrentModuleData[moduleId] = data;
 
			// disable module (this disables requires from this module)
			module.hot.active = false;
 
			// remove module from cache
			delete installedModules[moduleId];
 
			// remove "parents" references from all children
			for(j = 0; j < module.children.length; j++) {
				var child = installedModules[module.children[j]];
				if(!child) continue;
				idx = child.parents.indexOf(moduleId);
				if(idx >= 0) {
					child.parents.splice(idx, 1);
				}
			}
		}
 
		// remove outdated dependency from module children
		var dependency;
		var moduleOutdatedDependencies;
		for(moduleId in outdatedDependencies) {
			if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
				module = installedModules[moduleId];
				if(module) {
					moduleOutdatedDependencies = outdatedDependencies[moduleId];
					for(j = 0; j < moduleOutdatedDependencies.length; j++) {
						dependency = moduleOutdatedDependencies[j];
						idx = module.children.indexOf(dependency);
						if(idx >= 0) module.children.splice(idx, 1);
					}
				}
			}
		}
 
		// Not in "apply" phase
		hotSetStatus("apply");
 
		hotCurrentHash = hotUpdateNewHash;
 
		// insert new code
		for(moduleId in appliedUpdate) {
			if(Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) {
				modules[moduleId] = appliedUpdate[moduleId];
			}
		}
 
		// call accept handlers
		var error = null;
		for(moduleId in outdatedDependencies) {
			if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) {
				module = installedModules[moduleId];
				moduleOutdatedDependencies = outdatedDependencies[moduleId];
				var callbacks = [];
				for(i = 0; i < moduleOutdatedDependencies.length; i++) {
					dependency = moduleOutdatedDependencies[i];
					cb = module.hot._acceptedDependencies[dependency];
					if(callbacks.indexOf(cb) >= 0) continue;
					callbacks.push(cb);
				}
				for(i = 0; i < callbacks.length; i++) {
					cb = callbacks[i];
					try {
						cb(moduleOutdatedDependencies);
					} catch(err) {
						if(options.onErrored) {
							options.onErrored({
								type: "accept-errored",
								moduleId: moduleId,
								dependencyId: moduleOutdatedDependencies[i],
								error: err
							});
						}
						if(!options.ignoreErrored) {
							if(!error)
								error = err;
						}
					}
				}
			}
		}
 
		// Load self accepted modules
		for(i = 0; i < outdatedSelfAcceptedModules.length; i++) {
			var item = outdatedSelfAcceptedModules[i];
			moduleId = item.module;
			hotCurrentParents = [moduleId];
			try {
				$require$(moduleId);
			} catch(err) {
				if(typeof item.errorHandler === "function") {
					try {
						item.errorHandler(err);
					} catch(err2) {
						if(options.onErrored) {
							options.onErrored({
								type: "self-accept-error-handler-errored",
								moduleId: moduleId,
								error: err2,
								orginalError: err
							});
						}
						if(!options.ignoreErrored) {
							if(!error)
								error = err2;
						}
						if(!error)
							error = err;
					}
				} else {
					if(options.onErrored) {
						options.onErrored({
							type: "self-accept-errored",
							moduleId: moduleId,
							error: err
						});
					}
					if(!options.ignoreErrored) {
						if(!error)
							error = err;
					}
				}
			}
		}
 
		// handle errors in accept handlers and self accepted module load
		if(error) {
			hotSetStatus("fail");
			return Promise.reject(error);
		}
 
		hotSetStatus("idle");
		return Promise.resolve(outdatedModules);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HotModuleReplacementPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HotModuleReplacementPlugin.js

Statements: 6.18% (11 / 178)      Branches: 0% (0 / 71)      Functions: 0% (0 / 33)      Lines: 6.43% (11 / 171)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » HotModuleReplacementPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261          1 1 1 1 1 1 1   1         1   1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
var Template = require("./Template");
var ModuleHotAcceptDependency = require("./dependencies/ModuleHotAcceptDependency");
var ModuleHotDeclineDependency = require("./dependencies/ModuleHotDeclineDependency");
var RawSource = require("webpack-sources").RawSource;
var ConstDependency = require("./dependencies/ConstDependency");
var NullFactory = require("./NullFactory");
const ParserHelpers = require("./ParserHelpers");
 
function HotModuleReplacementPlugin(options) {
	options = options || {};
	this.multiStep = options.multiStep;
	this.fullBuildTimeout = options.fullBuildTimeout || 200;
}
module.exports = HotModuleReplacementPlugin;
 
HotModuleReplacementPlugin.prototype.apply = function(compiler) {
	var multiStep = this.multiStep;
	var fullBuildTimeout = this.fullBuildTimeout;
	var hotUpdateChunkFilename = compiler.options.output.hotUpdateChunkFilename;
	var hotUpdateMainFilename = compiler.options.output.hotUpdateMainFilename;
	compiler.plugin("compilation", function(compilation, params) {
		var hotUpdateChunkTemplate = compilation.hotUpdateChunkTemplate;
		if(!hotUpdateChunkTemplate) return;
 
		var normalModuleFactory = params.normalModuleFactory;
 
		compilation.dependencyFactories.set(ConstDependency, new NullFactory());
		compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 
		compilation.dependencyFactories.set(ModuleHotAcceptDependency, normalModuleFactory);
		compilation.dependencyTemplates.set(ModuleHotAcceptDependency, new ModuleHotAcceptDependency.Template());
 
		compilation.dependencyFactories.set(ModuleHotDeclineDependency, normalModuleFactory);
		compilation.dependencyTemplates.set(ModuleHotDeclineDependency, new ModuleHotDeclineDependency.Template());
 
		compilation.plugin("record", function(compilation, records) {
			if(records.hash === this.hash) return;
			records.hash = compilation.hash;
			records.moduleHashs = {};
			this.modules.forEach(function(module) {
				var identifier = module.identifier();
				var hash = require("crypto").createHash("md5");
				module.updateHash(hash);
				records.moduleHashs[identifier] = hash.digest("hex");
			});
			records.chunkHashs = {};
			this.chunks.forEach(function(chunk) {
				records.chunkHashs[chunk.id] = chunk.hash;
			});
			records.chunkModuleIds = {};
			this.chunks.forEach(function(chunk) {
				records.chunkModuleIds[chunk.id] = chunk.modules.map(function(m) {
					return m.id;
				});
			});
		});
		var initialPass = false;
		var recompilation = false;
		compilation.plugin("after-hash", function() {
			var records = this.records;
			if(!records) {
				initialPass = true;
				return;
			}
			if(!records.hash)
				initialPass = true;
			var preHash = records.preHash || "x";
			var prepreHash = records.prepreHash || "x";
			if(preHash === this.hash) {
				recompilation = true;
				this.modifyHash(prepreHash);
				return;
			}
			records.prepreHash = records.hash || "x";
			records.preHash = this.hash;
			this.modifyHash(records.prepreHash);
		});
		compilation.plugin("should-generate-chunk-assets", function() {
			if(multiStep && !recompilation && !initialPass)
				return false;
		});
		compilation.plugin("need-additional-pass", function() {
			if(multiStep && !recompilation && !initialPass)
				return true;
		});
		compiler.plugin("additional-pass", function(callback) {
			if(multiStep)
				return setTimeout(callback, fullBuildTimeout);
			return callback();
		});
		compilation.plugin("additional-chunk-assets", function() {
			var records = this.records;
			if(records.hash === this.hash) return;
			if(!records.moduleHashs || !records.chunkHashs || !records.chunkModuleIds) return;
			this.modules.forEach(function(module) {
				var identifier = module.identifier();
				var hash = require("crypto").createHash("md5");
				module.updateHash(hash);
				hash = hash.digest("hex");
				module.hotUpdate = records.moduleHashs[identifier] !== hash;
			});
			var hotUpdateMainContent = {
				h: this.hash,
				c: {}
			};
			Object.keys(records.chunkHashs).forEach(function(chunkId) {
				chunkId = isNaN(+chunkId) ? chunkId : +chunkId;
				var currentChunk = this.chunks.find(chunk => chunk.id === chunkId);
				if(currentChunk) {
					var newModules = currentChunk.modules.filter(function(module) {
						return module.hotUpdate;
					});
					var allModules = {};
					currentChunk.modules.forEach(function(module) {
						allModules[module.id] = true;
					});
					var removedModules = records.chunkModuleIds[chunkId].filter(function(id) {
						return !allModules[id];
					});
					if(newModules.length > 0 || removedModules.length > 0) {
						var source = hotUpdateChunkTemplate.render(chunkId, newModules, removedModules, this.hash, this.moduleTemplate, this.dependencyTemplates);
						var filename = this.getPath(hotUpdateChunkFilename, {
							hash: records.hash,
							chunk: currentChunk
						});
						this.additionalChunkAssets.push(filename);
						this.assets[filename] = source;
						hotUpdateMainContent.c[chunkId] = true;
						currentChunk.files.push(filename);
						this.applyPlugins("chunk-asset", currentChunk, filename);
					}
				} else {
					hotUpdateMainContent.c[chunkId] = false;
				}
			}, this);
			var source = new RawSource(JSON.stringify(hotUpdateMainContent));
			var filename = this.getPath(hotUpdateMainFilename, {
				hash: records.hash
			});
			this.assets[filename] = source;
		});
 
		compilation.mainTemplate.plugin("hash", function(hash) {
			hash.update("HotMainTemplateDecorator");
		});
 
		compilation.mainTemplate.plugin("module-require", function(_, chunk, hash, varModuleId) {
			return "hotCreateRequire(" + varModuleId + ")";
		});
 
		compilation.mainTemplate.plugin("require-extensions", function(source) {
			var buf = [source];
			buf.push("");
			buf.push("// __webpack_hash__");
			buf.push(this.requireFn + ".h = function() { return hotCurrentHash; };");
			return this.asString(buf);
		});
 
		compilation.mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
			source = this.applyPluginsWaterfall("hot-bootstrap", source, chunk, hash);
			return this.asString([
				source,
				"",
				hotInitCode
				.replace(/\$require\$/g, this.requireFn)
				.replace(/\$hash\$/g, JSON.stringify(hash))
				.replace(/\/\*foreachInstalledChunks\*\//g, chunk.chunks.length > 0 ? "for(var chunkId in installedChunks)" : "var chunkId = " + JSON.stringify(chunk.id) + ";")
			]);
		});
 
		compilation.mainTemplate.plugin("global-hash", function() {
			return true;
		});
 
		compilation.mainTemplate.plugin("current-hash", function(_, length) {
			if(isFinite(length))
				return "hotCurrentHash.substr(0, " + length + ")";
			else
				return "hotCurrentHash";
		});
 
		compilation.mainTemplate.plugin("module-obj", function(source, chunk, hash, varModuleId) {
			return this.asString([
				source + ",",
				"hot: hotCreateModule(" + varModuleId + "),",
				"parents: (hotCurrentParentsTemp = hotCurrentParents, hotCurrentParents = [], hotCurrentParentsTemp),",
				"children: []"
			]);
		});
 
		params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
			parser.plugin("expression __webpack_hash__", ParserHelpers.toConstantDependency("__webpack_require__.h()"));
			parser.plugin("evaluate typeof __webpack_hash__", ParserHelpers.evaluateToString("string"));
			parser.plugin("evaluate Identifier module.hot", function(expr) {
				return ParserHelpers.evaluateToBoolean(!!this.state.compilation.hotUpdateChunkTemplate)(expr);
			});
			parser.plugin("call module.hot.accept", function(expr) {
				if(!this.state.compilation.hotUpdateChunkTemplate) return false;
				if(expr.arguments.length >= 1) {
					var arg = this.evaluateExpression(expr.arguments[0]);
					var params = [],
						requests = [];
					if(arg.isString()) {
						params = [arg];
					} else if(arg.isArray()) {
						params = arg.items.filter(function(param) {
							return param.isString();
						});
					}
					if(params.length > 0) {
						params.forEach(function(param, idx) {
							var request = param.string;
							var dep = new ModuleHotAcceptDependency(request, param.range);
							dep.optional = true;
							dep.loc = Object.create(expr.loc);
							dep.loc.index = idx;
							this.state.module.addDependency(dep);
							requests.push(request);
						}.bind(this));
						if(expr.arguments.length > 1)
							this.applyPluginsBailResult("hot accept callback", expr.arguments[1], requests);
						else
							this.applyPluginsBailResult("hot accept without callback", expr, requests);
					}
				}
			});
			parser.plugin("call module.hot.decline", function(expr) {
				if(!this.state.compilation.hotUpdateChunkTemplate) return false;
				if(expr.arguments.length === 1) {
					var arg = this.evaluateExpression(expr.arguments[0]);
					var params = [];
					if(arg.isString()) {
						params = [arg];
					} else if(arg.isArray()) {
						params = arg.items.filter(function(param) {
							return param.isString();
						});
					}
					params.forEach(function(param, idx) {
						var dep = new ModuleHotDeclineDependency(param.string, param.range);
						dep.optional = true;
						dep.loc = Object.create(expr.loc);
						dep.loc.index = idx;
						this.state.module.addDependency(dep);
					}.bind(this));
				}
			});
			parser.plugin("expression module.hot", ParserHelpers.skipTraversal);
		});
	});
 
};
 
var hotInitCode = Template.getFunctionContent(require("./HotModuleReplacement.runtime.js"));
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HotUpdateChunkTemplate.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/HotUpdateChunkTemplate.js

Statements: 20% (2 / 10)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 20% (2 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32            1   1                                              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Template = require("./Template");
 
module.exports = class HotUpdateChunkTemplate extends Template {
	constructor(outputOptions) {
		super(outputOptions);
	}
 
	render(id, modules, removedModules, hash, moduleTemplate, dependencyTemplates) {
		const modulesSource = this.renderChunkModules({
			id: id,
			modules: modules,
			removedModules: removedModules
		}, moduleTemplate, dependencyTemplates);
		const core = this.applyPluginsWaterfall("modules", modulesSource, modules, removedModules, moduleTemplate, dependencyTemplates);
		const source = this.applyPluginsWaterfall("render", core, modules, removedModules, hash, id, moduleTemplate, dependencyTemplates);
		return source;
	}
 
	updateHash(hash) {
		hash.update("HotUpdateChunkTemplate");
		hash.update("1");
		this.applyPlugins("hash", hash);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/IgnorePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/IgnorePlugin.js

Statements: 5% (1 / 20)      Branches: 0% (0 / 10)      Functions: 0% (0 / 6)      Lines: 5% (1 / 20)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71                                                                                                                                        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class IgnorePlugin {
	constructor(resourceRegExp, contextRegExp) {
		this.resourceRegExp = resourceRegExp;
		this.contextRegExp = contextRegExp;
 
		this.checkIgnore = this.checkIgnore.bind(this);
	}
 
	/*
	 * Only returns true if a "resourceRegExp" exists
	 * and the resource given matches the regexp.
	 */
	checkResouce(resource) {
		if(!this.resourceRegExp) {
			return false;
		}
		return this.resourceRegExp.test(resource);
	}
 
	/*
	 * Returns true if contextRegExp does not exist
	 * or if context matches the given regexp.
	 */
	checkContext(context) {
		if(!this.contextRegExp) {
			return true;
		}
		return this.contextRegExp.test(context);
	}
 
	/*
	 * Returns true if result should be ignored.
	 * false if it shouldn't.
	 *
	 * Not that if "contextRegExp" is given, both the "resourceRegExp"
	 * and "contextRegExp" have to match.
	 */
	checkResult(result) {
		if(!result) {
			return true;
		}
		return this.checkResouce(result.request) && this.checkContext(result.context);
	}
 
	checkIgnore(result, callback) {
		// check if result is ignored
		if(this.checkResult(result)) {
			return callback();
		}
		return callback(null, result);
	}
 
	apply(compiler) {
		compiler.plugin("normal-module-factory", (nmf) => {
			nmf.plugin("before-resolve", this.checkIgnore);
		});
		compiler.plugin("context-module-factory", (cmf) => {
			cmf.plugin("before-resolve", this.checkIgnore);
		});
	}
}
 
module.exports = IgnorePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpChunkTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpChunkTemplatePlugin.js

Statements: 11.11% (2 / 18)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 11.76% (2 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            1                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
 
class JsonpChunkTemplatePlugin {
	apply(chunkTemplate) {
		chunkTemplate.plugin("render", function(modules, chunk) {
			const jsonpFunction = this.outputOptions.jsonpFunction;
			const source = new ConcatSource();
			source.add(`${jsonpFunction}(${JSON.stringify(chunk.ids)},`);
			source.add(modules);
			const entries = [chunk.entryModule].filter(Boolean).map(m => m.id);
			if(entries.length > 0) {
				source.add(`,${JSON.stringify(entries)}`);
			}
			source.add(")");
			return source;
		});
		chunkTemplate.plugin("hash", function(hash) {
			hash.update("JsonpChunkTemplatePlugin");
			hash.update("3");
			hash.update(`${this.outputOptions.jsonpFunction}`);
			hash.update(`${this.outputOptions.library}`);
		});
	}
}
module.exports = JsonpChunkTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpExportMainTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpExportMainTemplatePlugin.js

Statements: 14.29% (2 / 14)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 15.38% (2 / 13)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » JsonpExportMainTemplatePlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39            1                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
 
class JsonpExportMainTemplatePlugin {
	constructor(name) {
		this.name = name;
	}
 
	apply(compilation) {
		const mainTemplate = compilation.mainTemplate;
 
		compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
			const name = mainTemplate.applyPluginsWaterfall("asset-path", this.name || "", {
				hash: hash,
				chunk: chunk
			});
			return new ConcatSource(`${name}(`, source, ");");
		});
 
		mainTemplate.plugin("global-hash-paths", paths => {
			if(this.name) paths.push(this.name);
			return paths;
		});
 
		mainTemplate.plugin("hash", hash => {
			hash.update("jsonp export");
			hash.update(`${this.name}`);
		});
	}
}
 
module.exports = JsonpExportMainTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpHotUpdateChunkTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpHotUpdateChunkTemplatePlugin.js

Statements: 15.38% (2 / 13)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 15.38% (2 / 13)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » JsonpHotUpdateChunkTemplatePlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29            1                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
 
class JsonpHotUpdateChunkTemplatePlugin {
	apply(hotUpdateChunkTemplate) {
		hotUpdateChunkTemplate.plugin("render", function(modulesSource, modules, removedModules, hash, id) {
			const source = new ConcatSource();
			source.add(`${this.outputOptions.hotUpdateFunction}(${JSON.stringify(id)},`);
			source.add(modulesSource);
			source.add(")");
			return source;
		});
		hotUpdateChunkTemplate.plugin("hash", function(hash) {
			hash.update("JsonpHotUpdateChunkTemplatePlugin");
			hash.update("3");
			hash.update(`${this.outputOptions.hotUpdateFunction}`);
			hash.update(`${this.outputOptions.library}`);
		});
	}
}
 
module.exports = JsonpHotUpdateChunkTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpMainTemplate.runtime.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpMainTemplate.runtime.js

Statements: 10.81% (4 / 37)      Branches: 0% (0 / 14)      Functions: 0% (0 / 6)      Lines: 11.43% (4 / 35)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60          1 1         1                 1                                                                              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*globals hotAddUpdateChunk parentHotUpdateCallback document XMLHttpRequest $require$ $hotChunkFilename$ $hotMainFilename$ */
module.exports = function() {
	function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars
		hotAddUpdateChunk(chunkId, moreModules);
		if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules);
	} //$semicolon
 
	function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars
		var head = document.getElementsByTagName("head")[0];
		var script = document.createElement("script");
		script.type = "text/javascript";
		script.charset = "utf-8";
		script.src = $require$.p + $hotChunkFilename$;
		head.appendChild(script);
	}
 
	function hotDownloadManifest() { // eslint-disable-line no-unused-vars
		return new Promise(function(resolve, reject) {
			if(typeof XMLHttpRequest === "undefined")
				return reject(new Error("No browser support"));
			try {
				var request = new XMLHttpRequest();
				var requestPath = $require$.p + $hotMainFilename$;
				request.open("GET", requestPath, true);
				request.timeout = 10000;
				request.send(null);
			} catch(err) {
				return reject(err);
			}
			request.onreadystatechange = function() {
				if(request.readyState !== 4) return;
				if(request.status === 0) {
					// timeout
					reject(new Error("Manifest request to " + requestPath + " timed out."));
				} else if(request.status === 404) {
					// no update available
					resolve();
				} else if(request.status !== 200 && request.status !== 304) {
					// other failure
					reject(new Error("Manifest request to " + requestPath + " failed."));
				} else {
					// success
					try {
						var update = JSON.parse(request.responseText);
					} catch(e) {
						reject(e);
						return;
					}
					resolve(update);
				}
			};
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpMainTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpMainTemplatePlugin.js

Statements: 4.17% (2 / 48)      Branches: 0% (0 / 14)      Functions: 0% (0 / 9)      Lines: 4.26% (2 / 47)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210            1                                                                                                                                                                                                                                                                                                                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Template = require("./Template");
 
class JsonpMainTemplatePlugin {
 
	apply(mainTemplate) {
		mainTemplate.plugin("local-vars", function(source, chunk) {
			if(chunk.chunks.length > 0) {
				return this.asString([
					source,
					"",
					"// objects to store loaded and loading chunks",
					"var installedChunks = {",
					this.indent(
						chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(",\n")
					),
					"};"
				]);
			}
			return source;
		});
		mainTemplate.plugin("jsonp-script", function(_, chunk, hash) {
			const chunkFilename = this.outputOptions.chunkFilename;
			const chunkMaps = chunk.getChunkMaps();
			const crossOriginLoading = this.outputOptions.crossOriginLoading;
			const chunkLoadTimeout = this.outputOptions.chunkLoadTimeout || 120000;
			const scriptSrcPath = this.applyPluginsWaterfall("asset-path", JSON.stringify(chunkFilename), {
				hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
				hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
				chunk: {
					id: "\" + chunkId + \"",
					hash: `" + ${JSON.stringify(chunkMaps.hash)}[chunkId] + "`,
					hashWithLength(length) {
						const shortChunkHashMap = Object.create(null);
						Object.keys(chunkMaps.hash).forEach(chunkId => {
							if(typeof chunkMaps.hash[chunkId] === "string")
								shortChunkHashMap[chunkId] = chunkMaps.hash[chunkId].substr(0, length);
						});
						return `" + ${JSON.stringify(shortChunkHashMap)}[chunkId] + "`;
					},
					name: `" + (${JSON.stringify(chunkMaps.name)}[chunkId]||chunkId) + "`
				}
			});
			return this.asString([
				"var script = document.createElement('script');",
				"script.type = 'text/javascript';",
				"script.charset = 'utf-8';",
				"script.async = true;",
				`script.timeout = ${chunkLoadTimeout};`,
				crossOriginLoading ? `script.crossOrigin = ${JSON.stringify(crossOriginLoading)};` : "",
				`if (${this.requireFn}.nc) {`,
				this.indent(`script.setAttribute("nonce", ${this.requireFn}.nc);`),
				"}",
				`script.src = ${this.requireFn}.p + ${scriptSrcPath};`,
				`var timeout = setTimeout(onScriptComplete, ${chunkLoadTimeout});`,
				"script.onerror = script.onload = onScriptComplete;",
				"function onScriptComplete() {",
				this.indent([
					"// avoid mem leaks in IE.",
					"script.onerror = script.onload = null;",
					"clearTimeout(timeout);",
					"var chunk = installedChunks[chunkId];",
					"if(chunk !== 0) {",
					this.indent([
						"if(chunk) {",
						this.indent("chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));"),
						"}",
						"installedChunks[chunkId] = undefined;"
					]),
					"}"
				]),
				"};",
			]);
		});
		mainTemplate.plugin("require-ensure", function(_, chunk, hash) {
			return this.asString([
				"if(installedChunks[chunkId] === 0) {",
				this.indent([
					"return Promise.resolve();"
				]),
				"}",
				"",
				"// a Promise means \"currently loading\".",
				"if(installedChunks[chunkId]) {",
				this.indent([
					"return installedChunks[chunkId][2];"
				]),
				"}",
				"",
				"// setup Promise in chunk cache",
				"var promise = new Promise(function(resolve, reject) {",
				this.indent([
					"installedChunks[chunkId] = [resolve, reject];"
				]),
				"});",
				"installedChunks[chunkId][2] = promise;",
				"",
				"// start chunk loading",
				"var head = document.getElementsByTagName('head')[0];",
				this.applyPluginsWaterfall("jsonp-script", "", chunk, hash),
				"head.appendChild(script);",
				"",
				"return promise;"
			]);
		});
		mainTemplate.plugin("require-extensions", function(source, chunk) {
			if(chunk.chunks.length === 0) return source;
 
			return this.asString([
				source,
				"",
				"// on error function for async loading",
				`${this.requireFn}.oe = function(err) { console.error(err); throw err; };`
			]);
		});
		mainTemplate.plugin("bootstrap", function(source, chunk, hash) {
			if(chunk.chunks.length > 0) {
				var jsonpFunction = this.outputOptions.jsonpFunction;
				return this.asString([
					source,
					"",
					"// install a JSONP callback for chunk loading",
					`var parentJsonpFunction = window[${JSON.stringify(jsonpFunction)}];`,
					`window[${JSON.stringify(jsonpFunction)}] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {`,
					this.indent([
						"// add \"moreModules\" to the modules object,",
						"// then flag all \"chunkIds\" as loaded and fire callback",
						"var moduleId, chunkId, i = 0, resolves = [], result;",
						"for(;i < chunkIds.length; i++) {",
						this.indent([
							"chunkId = chunkIds[i];",
							"if(installedChunks[chunkId]) {",
							this.indent("resolves.push(installedChunks[chunkId][0]);"),
							"}",
							"installedChunks[chunkId] = 0;"
						]),
						"}",
						"for(moduleId in moreModules) {",
						this.indent([
							"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
							this.indent(this.renderAddModule(hash, chunk, "moduleId", "moreModules[moduleId]")),
							"}"
						]),
						"}",
						"if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);",
						"while(resolves.length) {",
						this.indent("resolves.shift()();"),
						"}",
						this.entryPointInChildren(chunk) ? [
							"if(executeModules) {",
							this.indent([
								"for(i=0; i < executeModules.length; i++) {",
								this.indent(`result = ${this.requireFn}(${this.requireFn}.s = executeModules[i]);`),
								"}"
							]),
							"}",
							"return result;",
						] : ""
					]),
					"};"
				]);
			}
			return source;
		});
		mainTemplate.plugin("hot-bootstrap", function(source, chunk, hash) {
			const hotUpdateChunkFilename = this.outputOptions.hotUpdateChunkFilename;
			const hotUpdateMainFilename = this.outputOptions.hotUpdateMainFilename;
			const hotUpdateFunction = this.outputOptions.hotUpdateFunction;
			const currentHotUpdateChunkFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateChunkFilename), {
				hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
				hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`,
				chunk: {
					id: "\" + chunkId + \""
				}
			});
			const currentHotUpdateMainFilename = this.applyPluginsWaterfall("asset-path", JSON.stringify(hotUpdateMainFilename), {
				hash: `" + ${this.renderCurrentHashCode(hash)} + "`,
				hashWithLength: length => `" + ${this.renderCurrentHashCode(hash, length)} + "`
			});
			const runtimeSource = Template.getFunctionContent(require("./JsonpMainTemplate.runtime.js"))
				.replace(/\/\/\$semicolon/g, ";")
				.replace(/\$require\$/g, this.requireFn)
				.replace(/\$hotMainFilename\$/g, currentHotUpdateMainFilename)
				.replace(/\$hotChunkFilename\$/g, currentHotUpdateChunkFilename)
				.replace(/\$hash\$/g, JSON.stringify(hash));
			return `${source}
function hotDisposeChunk(chunkId) {
	delete installedChunks[chunkId];
}
var parentHotUpdateCallback = this[${JSON.stringify(hotUpdateFunction)}];
this[${JSON.stringify(hotUpdateFunction)}] = ${runtimeSource}`;
		});
		mainTemplate.plugin("hash", function(hash) {
			hash.update("jsonp");
			hash.update("4");
			hash.update(`${this.outputOptions.filename}`);
			hash.update(`${this.outputOptions.chunkFilename}`);
			hash.update(`${this.outputOptions.jsonpFunction}`);
			hash.update(`${this.outputOptions.hotUpdateFunction}`);
		});
	}
}
module.exports = JsonpMainTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/JsonpTemplatePlugin.js

Statements: 50% (4 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 50% (4 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23            1 1 1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const JsonpMainTemplatePlugin = require("./JsonpMainTemplatePlugin");
const JsonpChunkTemplatePlugin = require("./JsonpChunkTemplatePlugin");
const JsonpHotUpdateChunkTemplatePlugin = require("./JsonpHotUpdateChunkTemplatePlugin");
 
class JsonpTemplatePlugin {
	apply(compiler) {
		compiler.plugin("this-compilation", (compilation) => {
			compilation.mainTemplate.apply(new JsonpMainTemplatePlugin());
			compilation.chunkTemplate.apply(new JsonpChunkTemplatePlugin());
			compilation.hotUpdateChunkTemplate.apply(new JsonpHotUpdateChunkTemplatePlugin());
		});
	}
}
 
module.exports = JsonpTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LibManifestPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LibManifestPlugin.js

Statements: 13.64% (3 / 22)      Branches: 0% (0 / 14)      Functions: 0% (0 / 2)      Lines: 14.29% (3 / 21)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60            1 1                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
const asyncLib = require("async");
 
class LibManifestPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		compiler.plugin("emit", (compilation, callback) => {
			asyncLib.forEach(compilation.chunks, (chunk, callback) => {
				if(!chunk.isInitial()) {
					callback();
					return;
				}
				const targetPath = compilation.getPath(this.options.path, {
					hash: compilation.hash,
					chunk
				});
				const name = this.options.name && compilation.getPath(this.options.name, {
					hash: compilation.hash,
					chunk
				});
				const manifest = {
					name,
					type: this.options.type,
					content: chunk.modules.reduce((obj, module) => {
						if(module.libIdent) {
							const ident = module.libIdent({
								context: this.options.context || compiler.options.context
							});
							if(ident) {
								obj[ident] = {
									id: module.id,
									meta: module.meta,
									exports: Array.isArray(module.providedExports) ? module.providedExports : undefined
								};
							}
						}
						return obj;
					}, {})
				};
				const content = new Buffer(JSON.stringify(manifest, null, 2), "utf8"); //eslint-disable-line
				compiler.outputFileSystem.mkdirp(path.dirname(targetPath), err => {
					if(err) return callback(err);
					compiler.outputFileSystem.writeFile(targetPath, content, callback);
				});
			}, callback);
		});
	}
}
module.exports = LibManifestPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LibraryTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LibraryTemplatePlugin.js

Statements: 9.09% (4 / 44)      Branches: 0% (0 / 27)      Functions: 0% (0 / 4)      Lines: 9.52% (4 / 42)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89            1   1           1                                                                                                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const SetVarMainTemplatePlugin = require("./SetVarMainTemplatePlugin");
 
function accessorToObjectAccess(accessor) {
	return accessor.map((a) => {
		return `[${JSON.stringify(a)}]`;
	}).join("");
}
 
function accessorAccess(base, accessor, joinWith) {
	accessor = [].concat(accessor);
	return accessor.map((a, idx) => {
		a = base ?
			base + accessorToObjectAccess(accessor.slice(0, idx + 1)) :
			accessor[0] + accessorToObjectAccess(accessor.slice(1, idx + 1));
		if(idx === accessor.length - 1) return a;
		if(idx === 0 && typeof base === "undefined") return `${a} = typeof ${a} === "object" ? ${a} : {}`;
		return `${a} = ${a} || {}`;
	}).join(joinWith || "; ");
}
 
class LibraryTemplatePlugin {
 
	constructor(name, target, umdNamedDefine, auxiliaryComment) {
		this.name = name;
		this.target = target;
		this.umdNamedDefine = umdNamedDefine;
		this.auxiliaryComment = auxiliaryComment;
	}
 
	apply(compiler) {
		compiler.plugin("this-compilation", (compilation) => {
			switch(this.target) {
				case "var":
					compilation.apply(new SetVarMainTemplatePlugin(`var ${accessorAccess(false, this.name)}`));
					break;
				case "assign":
					compilation.apply(new SetVarMainTemplatePlugin(accessorAccess(undefined, this.name)));
					break;
				case "this":
				case "window":
				case "global":
					if(this.name)
						compilation.apply(new SetVarMainTemplatePlugin(accessorAccess(this.target, this.name)));
					else
						compilation.apply(new SetVarMainTemplatePlugin(this.target, true));
					break;
				case "commonjs":
					if(this.name)
						compilation.apply(new SetVarMainTemplatePlugin(accessorAccess("exports", this.name)));
					else
						compilation.apply(new SetVarMainTemplatePlugin("exports", true));
					break;
				case "commonjs2":
				case "commonjs-module":
					compilation.apply(new SetVarMainTemplatePlugin("module.exports"));
					break;
				case "amd":
					var AmdMainTemplatePlugin = require("./AmdMainTemplatePlugin");
					compilation.apply(new AmdMainTemplatePlugin(this.name));
					break;
				case "umd":
				case "umd2":
					var UmdMainTemplatePlugin = require("./UmdMainTemplatePlugin");
					compilation.apply(new UmdMainTemplatePlugin(this.name, {
						optionalAmdExternalAsGlobal: this.target === "umd2",
						namedDefine: this.umdNamedDefine,
						auxiliaryComment: this.auxiliaryComment
					}));
					break;
				case "jsonp":
					var JsonpExportMainTemplatePlugin = require("./JsonpExportMainTemplatePlugin");
					compilation.apply(new JsonpExportMainTemplatePlugin(this.name));
					break;
				default:
					throw new Error(`${this.target} is not a valid Library target`);
			}
		});
	}
}
 
module.exports = LibraryTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LoaderOptionsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LoaderOptionsPlugin.js

Statements: 10% (2 / 20)      Branches: 0% (0 / 10)      Functions: 0% (0 / 2)      Lines: 11.76% (2 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38            1                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
 
class LoaderOptionsPlugin {
	constructor(options) {
		if(typeof options !== "object") options = {};
		if(!options.test) options.test = {
			test: () => true
		};
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("normal-module-loader", (context, module) => {
				const resource = module.resource;
				if(!resource) return;
				const i = resource.indexOf("?");
				if(ModuleFilenameHelpers.matchObject(options, i < 0 ? resource : resource.substr(0, i))) {
					const filterSet = new Set(["include", "exclude", "test"]);
					Object.keys(options)
						.filter((key) => !filterSet.has(key))
						.forEach((key) => context[key] = options[key]);
				}
			});
		});
	}
}
 
module.exports = LoaderOptionsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LoaderTargetPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/LoaderTargetPlugin.js

Statements: 20% (1 / 5)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 25% (1 / 4)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                                    1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class LoaderTargetPlugin {
	constructor(target) {
		this.target = target;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("normal-module-loader", (loaderContext) => loaderContext.target = this.target);
		});
	}
}
 
module.exports = LoaderTargetPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MainTemplate.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MainTemplate.js

Statements: 4.81% (5 / 104)      Branches: 0% (0 / 18)      Functions: 0% (0 / 10)      Lines: 4.9% (5 / 102)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237            1 1 1 1                               1                                                                                                                                                                                                                                                                                                                                                                                                                                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
const OriginalSource = require("webpack-sources").OriginalSource;
const PrefixSource = require("webpack-sources").PrefixSource;
const Template = require("./Template");
 
// require function shortcuts:
// __webpack_require__.s = the module id of the entry point
// __webpack_require__.c = the module cache
// __webpack_require__.m = the module functions
// __webpack_require__.p = the bundle public path
// __webpack_require__.i = the identity function used for harmony imports
// __webpack_require__.e = the chunk ensure function
// __webpack_require__.d = the exported propery define getter function
// __webpack_require__.o = Object.prototype.hasOwnProperty.call
// __webpack_require__.n = compatibility get default export
// __webpack_require__.h = the webpack hash
// __webpack_require__.oe = the uncatched error handler for the webpack runtime
// __webpack_require__.nc = the script nonce
 
module.exports = class MainTemplate extends Template {
	constructor(outputOptions) {
		super(outputOptions);
		this.plugin("startup", (source, chunk, hash) => {
			const buf = [];
			if(chunk.entryModule) {
				buf.push("// Load entry module and return exports");
				buf.push(`return ${this.renderRequireFunctionForModule(hash, chunk, JSON.stringify(chunk.entryModule.id))}(${this.requireFn}.s = ${JSON.stringify(chunk.entryModule.id)});`);
			}
			return this.asString(buf);
		});
		this.plugin("render", (bootstrapSource, chunk, hash, moduleTemplate, dependencyTemplates) => {
			const source = new ConcatSource();
			source.add("/******/ (function(modules) { // webpackBootstrap\n");
			source.add(new PrefixSource("/******/", bootstrapSource));
			source.add("/******/ })\n");
			source.add("/************************************************************************/\n");
			source.add("/******/ (");
			const modules = this.renderChunkModules(chunk, moduleTemplate, dependencyTemplates, "/******/ ");
			source.add(this.applyPluginsWaterfall("modules", modules, chunk, hash, moduleTemplate, dependencyTemplates));
			source.add(")");
			return source;
		});
		this.plugin("local-vars", (source, chunk, hash) => {
			return this.asString([
				source,
				"// The module cache",
				"var installedModules = {};"
			]);
		});
		this.plugin("require", (source, chunk, hash) => {
			return this.asString([
				source,
				"// Check if module is in cache",
				"if(installedModules[moduleId]) {",
				this.indent("return installedModules[moduleId].exports;"),
				"}",
				"// Create a new module (and put it into the cache)",
				"var module = installedModules[moduleId] = {",
				this.indent(this.applyPluginsWaterfall("module-obj", "", chunk, hash, "moduleId")),
				"};",
				"",
				this.asString(outputOptions.strictModuleExceptionHandling ? [
					"// Execute the module function",
					"var threw = true;",
					"try {",
					this.indent([
						`modules[moduleId].call(module.exports, module, module.exports, ${this.renderRequireFunctionForModule(hash, chunk, "moduleId")});`,
						"threw = false;"
					]),
					"} finally {",
					this.indent([
						"if(threw) delete installedModules[moduleId];"
					]),
					"}"
				] : [
					"// Execute the module function",
					`modules[moduleId].call(module.exports, module, module.exports, ${this.renderRequireFunctionForModule(hash, chunk, "moduleId")});`,
				]),
				"",
				"// Flag the module as loaded",
				"module.l = true;",
				"",
				"// Return the exports of the module",
				"return module.exports;"
			]);
		});
		this.plugin("module-obj", (source, chunk, hash, varModuleId) => {
			return this.asString([
				"i: moduleId,",
				"l: false,",
				"exports: {}"
			]);
		});
		this.plugin("require-extensions", (source, chunk, hash) => {
			const buf = [];
			if(chunk.chunks.length > 0) {
				buf.push("// This file contains only the entry chunk.");
				buf.push("// The chunk loading function for additional chunks");
				buf.push(`${this.requireFn}.e = function requireEnsure(chunkId) {`);
				buf.push(this.indent(this.applyPluginsWaterfall("require-ensure", "throw new Error('Not chunk loading available');", chunk, hash, "chunkId")));
				buf.push("};");
			}
			buf.push("");
			buf.push("// expose the modules object (__webpack_modules__)");
			buf.push(`${this.requireFn}.m = modules;`);
 
			buf.push("");
			buf.push("// expose the module cache");
			buf.push(`${this.requireFn}.c = installedModules;`);
 
			buf.push("");
			buf.push("// identity function for calling harmony imports with the correct context");
			buf.push(`${this.requireFn}.i = function(value) { return value; };`);
 
			buf.push("");
			buf.push("// define getter function for harmony exports");
			buf.push(`${this.requireFn}.d = function(exports, name, getter) {`);
			buf.push(this.indent([
				`if(!${this.requireFn}.o(exports, name)) {`,
				this.indent([
					"Object.defineProperty(exports, name, {",
					this.indent([
						"configurable: false,",
						"enumerable: true,",
						"get: getter"
					]),
					"});"
				]),
				"}"
			]));
			buf.push("};");
 
			buf.push("");
			buf.push("// getDefaultExport function for compatibility with non-harmony modules");
			buf.push(this.requireFn + ".n = function(module) {");
			buf.push(this.indent([
				"var getter = module && module.__esModule ?",
				this.indent([
					"function getDefault() { return module['default']; } :",
					"function getModuleExports() { return module; };"
				]),
				`${this.requireFn}.d(getter, 'a', getter);`,
				"return getter;"
			]));
			buf.push("};");
 
			buf.push("");
			buf.push("// Object.prototype.hasOwnProperty.call");
			buf.push(`${this.requireFn}.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };`);
 
			const publicPath = this.getPublicPath({
				hash: hash
			});
			buf.push("");
			buf.push("// __webpack_public_path__");
			buf.push(`${this.requireFn}.p = ${JSON.stringify(publicPath)};`);
			return this.asString(buf);
		});
 
		this.requireFn = "__webpack_require__";
	}
 
	render(hash, chunk, moduleTemplate, dependencyTemplates) {
		const buf = [];
		buf.push(this.applyPluginsWaterfall("bootstrap", "", chunk, hash, moduleTemplate, dependencyTemplates));
		buf.push(this.applyPluginsWaterfall("local-vars", "", chunk, hash));
		buf.push("");
		buf.push("// The require function");
		buf.push(`function ${this.requireFn}(moduleId) {`);
		buf.push(this.indent(this.applyPluginsWaterfall("require", "", chunk, hash)));
		buf.push("}");
		buf.push("");
		buf.push(this.asString(this.applyPluginsWaterfall("require-extensions", "", chunk, hash)));
		buf.push("");
		buf.push(this.asString(this.applyPluginsWaterfall("startup", "", chunk, hash)));
		let source = this.applyPluginsWaterfall("render", new OriginalSource(this.prefix(buf, " \t") + "\n", `webpack/bootstrap ${hash}`), chunk, hash, moduleTemplate, dependencyTemplates);
		if(chunk.hasEntryModule()) {
			source = this.applyPluginsWaterfall("render-with-entry", source, chunk, hash);
		}
		if(!source) throw new Error("Compiler error: MainTemplate plugin 'render' should return something");
		chunk.rendered = true;
		return new ConcatSource(source, ";");
	}
 
	renderRequireFunctionForModule(hash, chunk, varModuleId) {
		return this.applyPluginsWaterfall("module-require", this.requireFn, chunk, hash, varModuleId);
	}
 
	renderAddModule(hash, chunk, varModuleId, varModule) {
		return this.applyPluginsWaterfall("add-module", `modules[${varModuleId}] = ${varModule};`, chunk, hash, varModuleId, varModule);
	}
 
	renderCurrentHashCode(hash, length) {
		length = length || Infinity;
		return this.applyPluginsWaterfall("current-hash", JSON.stringify(hash.substr(0, length)), length);
	}
 
	entryPointInChildren(chunk) {
		const checkChildren = (chunk, alreadyCheckedChunks) => {
			return chunk.chunks.some((child) => {
				if(alreadyCheckedChunks.indexOf(child) >= 0) return;
				alreadyCheckedChunks.push(child);
				return child.hasEntryModule() || checkChildren(child, alreadyCheckedChunks);
			});
		};
		return checkChildren(chunk, []);
	}
 
	getPublicPath(options) {
		return this.applyPluginsWaterfall("asset-path", this.outputOptions.publicPath || "", options);
	}
 
	updateHash(hash) {
		hash.update("maintemplate");
		hash.update("3");
		hash.update(this.outputOptions.publicPath + "");
		this.applyPlugins("hash", hash);
	}
 
	updateHashForChunk(hash, chunk) {
		this.updateHash(hash);
		this.applyPlugins("hash-for-chunk", hash, chunk);
	}
 
	useChunkHash(chunk) {
		const paths = this.applyPluginsWaterfall("global-hash-paths", []);
		return !this.applyPluginsBailResult("global-hash", chunk, paths);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MemoryOutputFileSystem.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MemoryOutputFileSystem.js

Statements: 100% (1 / 1)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 100% (1 / 1)      Ignored: none     

1 2 3 4 5 6 7        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
module.exports = require("memory-fs");
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Module.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Module.js

Statements: 11.86% (14 / 118)      Branches: 0% (0 / 40)      Functions: 0% (0 / 20)      Lines: 12.61% (14 / 111)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190            1 1 1   1             1       1                                                                                                                                                                                                                                                                                                           1                 1 1 1 1 1 1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const DependenciesBlock = require("./DependenciesBlock");
const ModuleReason = require("./ModuleReason");
const Template = require("./Template");
 
function addToSet(set, items) {
	for(let item of items) {
		if(set.indexOf(item) < 0)
			set.push(item);
	}
}
 
function byId(a, b) {
	return a.id - b.id;
}
 
let debugId = 1000;
 
class Module extends DependenciesBlock {
	constructor() {
		super();
		this.context = null;
		this.reasons = [];
		this.debugId = debugId++;
		this.lastId = -1;
		this.id = null;
		this.portableId = null;
		this.index = null;
		this.index2 = null;
		this.depth = null;
		this.used = null;
		this.usedExports = null;
		this.providedExports = null;
		this.chunks = [];
		this.warnings = [];
		this.dependenciesWarnings = [];
		this.errors = [];
		this.dependenciesErrors = [];
		this.strict = false;
		this.meta = {};
	}
 
	disconnect() {
		this.reasons.length = 0;
		this.lastId = this.id;
		this.id = null;
		this.index = null;
		this.index2 = null;
		this.depth = null;
		this.used = null;
		this.usedExports = null;
		this.providedExports = null;
		this.chunks.length = 0;
		super.disconnect();
	}
 
	unseal() {
		this.lastId = this.id;
		this.id = null;
		this.index = null;
		this.index2 = null;
		this.depth = null;
		this.chunks.length = 0;
		super.unseal();
	}
 
	addChunk(chunk) {
		let idx = this.chunks.indexOf(chunk);
		if(idx < 0)
			this.chunks.push(chunk);
	}
 
	removeChunk(chunk) {
		let idx = this.chunks.indexOf(chunk);
		if(idx >= 0) {
			this.chunks.splice(idx, 1);
			chunk.removeModule(this);
			return true;
		}
		return false;
	}
 
	addReason(module, dependency) {
		this.reasons.push(new ModuleReason(module, dependency));
	}
 
	removeReason(module, dependency) {
		for(let i = 0; i < this.reasons.length; i++) {
			let r = this.reasons[i];
			if(r.module === module && r.dependency === dependency) {
				this.reasons.splice(i, 1);
				return true;
			}
		}
		return false;
	}
 
	hasReasonForChunk(chunk) {
		for(let r of this.reasons) {
			if(r.chunks) {
				if(r.chunks.indexOf(chunk) >= 0)
					return true;
			} else if(r.module.chunks.indexOf(chunk) >= 0)
				return true;
		}
		return false;
	}
 
	rewriteChunkInReasons(oldChunk, newChunks) {
		this.reasons.forEach(r => {
			if(!r.chunks) {
				if(r.module.chunks.indexOf(oldChunk) < 0)
					return;
				r.chunks = r.module.chunks;
			}
			r.chunks = r.chunks.reduce((arr, c) => {
				addToSet(arr, c !== oldChunk ? [c] : newChunks);
				return arr;
			}, []);
		});
	}
 
	isUsed(exportName) {
		if(this.used === null) return exportName;
		if(!exportName) return !!this.used;
		if(!this.used) return false;
		if(!this.usedExports) return false;
		if(this.usedExports === true) return exportName;
		let idx = this.usedExports.indexOf(exportName);
		if(idx < 0) return false;
		if(this.isProvided(exportName))
			return Template.numberToIdentifer(idx);
		return exportName;
	}
 
	isProvided(exportName) {
		if(!Array.isArray(this.providedExports))
			return null;
		return this.providedExports.indexOf(exportName) >= 0;
	}
 
	toString() {
		return `Module[${this.id || this.debugId}]`;
	}
 
	needRebuild(fileTimestamps, contextTimestamps) {
		return true;
	}
 
	updateHash(hash) {
		hash.update(this.id + "" + this.used);
		hash.update(JSON.stringify(this.usedExports));
		super.updateHash(hash);
	}
 
	sortItems() {
		super.sortItems();
		this.chunks.sort(byId);
		this.reasons.sort((a, b) => byId(a.module, b.module));
	}
 
	unbuild() {
		this.disconnect();
	}
}
 
Object.defineProperty(Module.prototype, "entry", {
	configurable: false,
	get() {
		throw new Error("Module.entry was removed. Use Chunk.entryModule");
	},
	set() {
		throw new Error("Module.entry was removed. Use Chunk.entryModule");
	}
});
Module.prototype.identifier = null;
Module.prototype.readableIdentifier = null;
Module.prototype.build = null;
Module.prototype.source = null;
Module.prototype.size = null;
Module.prototype.nameForCondition = null;
 
module.exports = Module;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleBuildError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleBuildError.js

Statements: 14.29% (3 / 21)      Branches: 0% (0 / 18)      Functions: 0% (0 / 1)      Lines: 14.29% (3 / 21)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44            1 1                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
const cutOffLoaderExecution = require("./ErrorHelpers").cutOffLoaderExecution;
 
class ModuleBuildError extends WebpackError {
	constructor(module, err) {
		super();
 
		this.name = "ModuleBuildError";
		this.message = "Module build failed: ";
		if(err !== null && typeof err === "object") {
			if(typeof err.stack === "string" && err.stack) {
				var stack = cutOffLoaderExecution(err.stack);
				if(!err.hideStack) {
					this.message += stack;
				} else {
					this.details = stack;
					if(typeof err.message === "string" && err.message) {
						this.message += err.message;
					} else {
						this.message += err;
					}
				}
			} else if(typeof err.message === "string" && err.message) {
				this.message += err.message;
			} else {
				this.message += err;
			}
		}
		this.module = module;
		this.error = err;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = ModuleBuildError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleDependencyError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleDependencyError.js

Statements: 30% (3 / 10)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 30% (3 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24            1 1   1                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
const formatLocation = require("./formatLocation");
 
module.exports = class ModuleDependencyError extends WebpackError {
	constructor(module, err, loc) {
		super();
 
		this.name = "ModuleDependencyError";
		this.message = `${formatLocation(loc)} ${err.message}`;
		this.details = err.stack.split("\n").slice(1).join("\n");
		this.origin = this.module = module;
		this.error = err;
 
		Error.captureStackTrace(this, this.constructor);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleDependencyWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleDependencyWarning.js

Statements: 30% (3 / 10)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 30% (3 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24            1 1   1                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
const formatLocation = require("./formatLocation");
 
module.exports = class ModuleDependencyWarning extends WebpackError {
	constructor(module, err, loc) {
		super();
 
		this.name = "ModuleDependencyWarning";
		this.message = `${formatLocation(loc)} ${err.message}`;
		this.details = err.stack.split("\n").slice(1).join("\n");
		this.origin = this.module = module;
		this.error = err;
 
		Error.captureStackTrace(this, this.constructor);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleError.js

Statements: 30% (3 / 10)      Branches: 0% (0 / 10)      Functions: 0% (0 / 1)      Lines: 30% (3 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            1 1                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
const cleanUp = require("./ErrorHelpers").cleanUp;
 
class ModuleError extends WebpackError {
	constructor(module, err) {
		super();
 
		this.name = "ModuleError";
		this.module = module;
		this.message = err && typeof err === "object" && err.message ? err.message : err;
		this.error = err;
		this.details = err && typeof err === "object" && err.stack ? cleanUp(err.stack, this.message) : undefined;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = ModuleError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleFilenameHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleFilenameHelpers.js

Statements: 28.85% (30 / 104)      Branches: 0% (0 / 42)      Functions: 0% (0 / 10)      Lines: 30.93% (30 / 97)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164            1   1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1   1         1         1           1         1                                                                                                     1                                   1                                           1                       1                    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ModuleFilenameHelpers = exports;
 
ModuleFilenameHelpers.ALL_LOADERS_RESOURCE = "[all-loaders][resource]";
ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE = /\[all-?loaders\]\[resource\]/gi;
ModuleFilenameHelpers.LOADERS_RESOURCE = "[loaders][resource]";
ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE = /\[loaders\]\[resource\]/gi;
ModuleFilenameHelpers.RESOURCE = "[resource]";
ModuleFilenameHelpers.REGEXP_RESOURCE = /\[resource\]/gi;
ModuleFilenameHelpers.ABSOLUTE_RESOURCE_PATH = "[absolute-resource-path]";
ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH = /\[abs(olute)?-?resource-?path\]/gi;
ModuleFilenameHelpers.RESOURCE_PATH = "[resource-path]";
ModuleFilenameHelpers.REGEXP_RESOURCE_PATH = /\[resource-?path\]/gi;
ModuleFilenameHelpers.ALL_LOADERS = "[all-loaders]";
ModuleFilenameHelpers.REGEXP_ALL_LOADERS = /\[all-?loaders\]/gi;
ModuleFilenameHelpers.LOADERS = "[loaders]";
ModuleFilenameHelpers.REGEXP_LOADERS = /\[loaders\]/gi;
ModuleFilenameHelpers.QUERY = "[query]";
ModuleFilenameHelpers.REGEXP_QUERY = /\[query\]/gi;
ModuleFilenameHelpers.ID = "[id]";
ModuleFilenameHelpers.REGEXP_ID = /\[id\]/gi;
ModuleFilenameHelpers.HASH = "[hash]";
ModuleFilenameHelpers.REGEXP_HASH = /\[hash\]/gi;
 
function getAfter(str, token) {
	const idx = str.indexOf(token);
	return idx < 0 ? "" : str.substr(idx);
}
 
function getBefore(str, token) {
	const idx = str.lastIndexOf(token);
	return idx < 0 ? "" : str.substr(0, idx);
}
 
function getHash(str) {
	const hash = require("crypto").createHash("md5");
	hash.update(str);
	return hash.digest("hex").substr(0, 4);
}
 
function asRegExp(test) {
	if(typeof test === "string") test = new RegExp("^" + test.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"));
	return test;
}
 
ModuleFilenameHelpers.createFilename = function createFilename(module, moduleFilenameTemplate, requestShortener) {
	let absoluteResourcePath;
	let hash;
	let identifier;
	let moduleId;
	let shortIdentifier;
	if(module === undefined) module = "";
	if(typeof module === "string") {
		shortIdentifier = requestShortener.shorten(module);
		identifier = shortIdentifier;
		moduleId = "";
		absoluteResourcePath = module.split("!").pop();
		hash = getHash(identifier);
	} else {
		shortIdentifier = module.readableIdentifier(requestShortener);
		identifier = requestShortener.shorten(module.identifier());
		moduleId = module.id;
		absoluteResourcePath = module.identifier().split("!").pop();
		hash = getHash(identifier);
	}
	const resource = shortIdentifier.split("!").pop();
	const loaders = getBefore(shortIdentifier, "!");
	const allLoaders = getBefore(identifier, "!");
	const query = getAfter(resource, "?");
	const resourcePath = resource.substr(0, resource.length - query.length);
	if(typeof moduleFilenameTemplate === "function") {
		return moduleFilenameTemplate({
			identifier: identifier,
			shortIdentifier: shortIdentifier,
			resource: resource,
			resourcePath: resourcePath,
			absoluteResourcePath: absoluteResourcePath,
			allLoaders: allLoaders,
			query: query,
			moduleId: moduleId,
			hash: hash
		});
	}
	return moduleFilenameTemplate
		.replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS_RESOURCE, identifier)
		.replace(ModuleFilenameHelpers.REGEXP_LOADERS_RESOURCE, shortIdentifier)
		.replace(ModuleFilenameHelpers.REGEXP_RESOURCE, resource)
		.replace(ModuleFilenameHelpers.REGEXP_RESOURCE_PATH, resourcePath)
		.replace(ModuleFilenameHelpers.REGEXP_ABSOLUTE_RESOURCE_PATH, absoluteResourcePath)
		.replace(ModuleFilenameHelpers.REGEXP_ALL_LOADERS, allLoaders)
		.replace(ModuleFilenameHelpers.REGEXP_LOADERS, loaders)
		.replace(ModuleFilenameHelpers.REGEXP_QUERY, query)
		.replace(ModuleFilenameHelpers.REGEXP_ID, moduleId)
		.replace(ModuleFilenameHelpers.REGEXP_HASH, hash);
};
 
ModuleFilenameHelpers.createFooter = function createFooter(module, requestShortener) {
	if(!module) module = "";
	if(typeof module === "string") {
		return [
			"// WEBPACK FOOTER //",
			`// ${requestShortener.shorten(module)}`
		].join("\n");
	} else {
		return [
			"//////////////////",
			"// WEBPACK FOOTER",
			`// ${module.readableIdentifier(requestShortener)}`,
			`// module id = ${module.id}`,
			`// module chunks = ${module.chunks.map(c => c.id).join(" ")}`
		].join("\n");
	}
};
 
ModuleFilenameHelpers.replaceDuplicates = function replaceDuplicates(array, fn, comparator) {
	const countMap = Object.create(null);
	const posMap = Object.create(null);
	array.forEach((item, idx) => {
		countMap[item] = (countMap[item] || []);
		countMap[item].push(idx);
		posMap[item] = 0;
	});
	if(comparator) {
		Object.keys(countMap).forEach(item => {
			countMap[item].sort(comparator);
		});
	}
	return array.map((item, i) => {
		if(countMap[item].length > 1) {
			if(comparator && countMap[item][0] === i)
				return item;
			return fn(item, i, posMap[item]++);
		} else return item;
	});
};
 
ModuleFilenameHelpers.matchPart = function matchPart(str, test) {
	if(!test) return true;
	test = asRegExp(test);
	if(Array.isArray(test)) {
		return test.map(asRegExp).filter(function(regExp) {
			return regExp.test(str);
		}).length > 0;
	} else {
		return test.test(str);
	}
};
 
ModuleFilenameHelpers.matchObject = function matchObject(obj, str) {
	if(obj.test)
		if(!ModuleFilenameHelpers.matchPart(str, obj.test)) return false;
	if(obj.include)
		if(!ModuleFilenameHelpers.matchPart(str, obj.include)) return false;
	if(obj.exclude)
		if(ModuleFilenameHelpers.matchPart(str, obj.exclude)) return false;
	return true;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleNotFoundError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleNotFoundError.js

Statements: 16.67% (2 / 12)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 16.67% (2 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28            1                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
 
class ModuleNotFoundError extends WebpackError {
	constructor(module, err, dependencies) {
		super();
 
		this.name = "ModuleNotFoundError";
		this.message = "Module not found: " + err;
		this.details = err.details;
		this.missing = err.missing;
		this.module = module;
		this.origin = module;
		this.dependencies = dependencies;
		this.error = err;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = ModuleNotFoundError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleParseError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleParseError.js

Statements: 12.5% (2 / 16)      Branches: 0% (0 / 7)      Functions: 0% (0 / 1)      Lines: 12.5% (2 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36            1                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
 
class ModuleParseError extends WebpackError {
	constructor(module, source, err) {
		super();
 
		this.name = "ModuleParseError";
		this.message = "Module parse failed: " + module.request + " " + err.message;
		this.message += "\nYou may need an appropriate loader to handle this file type.";
		if(err.loc && typeof err.loc === "object" && typeof err.loc.line === "number") {
			var lineNumber = err.loc.line;
			if(/[\0\u0001\u0002\u0003\u0004\u0005\u0006\u0007]/.test(source)) { // binary file
				this.message += "\n(Source code omitted for this binary file)";
			} else {
				source = source.split("\n");
				this.message += "\n| " + source.slice(Math.max(0, lineNumber - 3), lineNumber + 2).join("\n| ");
			}
		} else {
			this.message += "\n" + err.stack;
		}
		this.module = module;
		this.error = err;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = ModuleParseError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleReason.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleReason.js

Statements: 33.33% (1 / 3)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 33.33% (1 / 3)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14            1              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
module.exports = class ModuleReason {
	constructor(module, dependency) {
		this.module = module;
		this.dependency = dependency;
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleTemplate.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleTemplate.js

Statements: 22.22% (2 / 9)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 22.22% (2 / 9)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25            1   1                                
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Template = require("./Template");
 
module.exports = class ModuleTemplate extends Template {
	constructor(outputOptions) {
		super(outputOptions);
	}
	render(module, dependencyTemplates, chunk) {
		const moduleSource = module.source(dependencyTemplates, this.outputOptions, this.requestShortener);
		const moduleSourcePostModule = this.applyPluginsWaterfall("module", moduleSource, module, chunk, dependencyTemplates);
		const moduleSourcePostRender = this.applyPluginsWaterfall("render", moduleSourcePostModule, module, chunk, dependencyTemplates);
		return this.applyPluginsWaterfall("package", moduleSourcePostRender, module, chunk, dependencyTemplates);
	}
	updateHash(hash) {
		hash.update("1");
		this.applyPlugins("hash", hash);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ModuleWarning.js

Statements: 30% (3 / 10)      Branches: 0% (0 / 10)      Functions: 0% (0 / 1)      Lines: 30% (3 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26            1 1                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
const cleanUp = require("./ErrorHelpers").cleanUp;
 
class ModuleWarning extends WebpackError {
	constructor(module, warning) {
		super();
 
		this.name = "ModuleWarning";
		this.module = module;
		this.message = warning && typeof warning === "object" && warning.message ? warning.message : warning;
		this.warning = warning;
		this.details = warning && typeof warning === "object" && warning.stack ? cleanUp(warning.stack, this.message) : undefined;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = ModuleWarning;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MovedToPluginWarningPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MovedToPluginWarningPlugin.js

Statements: 14.29% (1 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 14.29% (1 / 7)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » MovedToPluginWarningPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23          1                                  
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
module.exports = class MovedToPluginWarningPlugin {
	constructor(optionName, pluginName) {
		this.optionName = optionName;
		this.pluginName = pluginName;
	}
	apply(compiler) {
		const optionName = this.optionName;
		const pluginName = this.pluginName;
		compiler.plugin("compilation", (compilation) => {
			compilation.warnings.push(new Error `webpack options:
			DEPRECATED option ${optionName} will be moved to the ${pluginName}. 
			Use this instead.
			For more info about the usage of the ${pluginName} see https://webpack.js.org/plugins/`);
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiCompiler.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiCompiler.js

Statements: 14.04% (16 / 114)      Branches: 0% (0 / 42)      Functions: 0% (0 / 30)      Lines: 14.68% (16 / 109)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178        1 1 1 1   1                   1                                                                                                         1   1 1   1       1       1                             1                         1                                                                             1                                   1              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var Tapable = require("tapable");
var asyncLib = require("async");
var MultiWatching = require("./MultiWatching");
var MultiStats = require("./MultiStats");
 
function MultiCompiler(compilers) {
	Tapable.call(this);
	if(!Array.isArray(compilers)) {
		compilers = Object.keys(compilers).map(function(name) {
			compilers[name].name = name;
			return compilers[name];
		});
	}
	this.compilers = compilers;
 
	function delegateProperty(name) {
		Object.defineProperty(this, name, {
			configurable: false,
			get: function() {
				throw new Error("Cannot read " + name + " of a MultiCompiler");
			},
			set: function(value) {
				this.compilers.forEach(function(compiler) {
					compiler[name] = value;
				});
			}.bind(this)
		});
	}
	delegateProperty.call(this, "outputFileSystem");
	delegateProperty.call(this, "inputFileSystem");
 
	Object.defineProperty(this, "outputPath", {
		configurable: false,
		get: function() {
			var commonPath = compilers[0].outputPath;
			for(var i = 1; i < compilers.length; i++) {
				while(compilers[i].outputPath.indexOf(commonPath) !== 0 && /[\/\\]/.test(commonPath)) {
					commonPath = commonPath.replace(/[\/\\][^\/\\]*$/, "");
				}
			}
			if(!commonPath && compilers[0].outputPath[0] === "/") return "/";
			return commonPath;
		}
	});
 
	var doneCompilers = 0;
	var compilerStats = [];
	this.compilers.forEach(function(compiler, idx) {
		var compilerDone = false;
		compiler.plugin("done", function(stats) {
			if(!compilerDone) {
				compilerDone = true;
				doneCompilers++;
			}
			compilerStats[idx] = stats;
			if(doneCompilers === this.compilers.length) {
				this.applyPlugins("done", new MultiStats(compilerStats));
			}
		}.bind(this));
		compiler.plugin("invalid", function() {
			if(compilerDone) {
				compilerDone = false;
				doneCompilers--;
			}
			this.applyPlugins("invalid");
		}.bind(this));
	}, this);
}
module.exports = MultiCompiler;
 
MultiCompiler.prototype = Object.create(Tapable.prototype);
MultiCompiler.prototype.constructor = MultiCompiler;
 
function runWithDependencies(compilers, fn, callback) {
	var fulfilledNames = {};
	var remainingCompilers = compilers;
 
	function isDependencyFulfilled(d) {
		return fulfilledNames[d];
	}
 
	function getReadyCompilers() {
		var readyCompilers = [];
		var list = remainingCompilers;
		remainingCompilers = [];
		for(var i = 0; i < list.length; i++) {
			var c = list[i];
			var ready = !c.dependencies || c.dependencies.every(isDependencyFulfilled);
			if(ready)
				readyCompilers.push(c);
			else
				remainingCompilers.push(c);
		}
		return readyCompilers;
	}
 
	function runCompilers(callback) {
		if(remainingCompilers.length === 0) return callback();
		asyncLib.map(getReadyCompilers(), function(compiler, callback) {
			fn(compiler, function(err) {
				if(err) return callback(err);
				fulfilledNames[compiler.name] = true;
				runCompilers(callback);
			});
		}, callback);
	}
	runCompilers(callback);
}
 
MultiCompiler.prototype.watch = function(watchOptions, handler) {
	var watchings = [];
	var allStats = this.compilers.map(function() {
		return null;
	});
	var compilerStatus = this.compilers.map(function() {
		return false;
	});
	runWithDependencies(this.compilers, function(compiler, callback) {
		var compilerIdx = this.compilers.indexOf(compiler);
		var firstRun = true;
		var watching = compiler.watch(Array.isArray(watchOptions) ? watchOptions[compilerIdx] : watchOptions, function(err, stats) {
			if(err)
				handler(err);
			if(stats) {
				allStats[compilerIdx] = stats;
				compilerStatus[compilerIdx] = "new";
				if(compilerStatus.every(Boolean)) {
					var freshStats = allStats.filter(function(s, idx) {
						return compilerStatus[idx] === "new";
					});
					compilerStatus.fill(true);
					var multiStats = new MultiStats(freshStats);
					handler(null, multiStats);
				}
			}
			if(firstRun && !err) {
				firstRun = false;
				callback();
			}
		});
		watchings.push(watching);
	}.bind(this), function() {
		// ignore
	});
 
	return new MultiWatching(watchings, this);
};
 
MultiCompiler.prototype.run = function(callback) {
	var allStats = this.compilers.map(function() {
		return null;
	});
 
	runWithDependencies(this.compilers, function(compiler, callback) {
		var compilerIdx = this.compilers.indexOf(compiler);
		compiler.run(function(err, stats) {
			if(err) return callback(err);
			allStats[compilerIdx] = stats;
			callback();
		});
	}.bind(this), function(err) {
		if(err) return callback(err);
		callback(null, new MultiStats(allStats));
	});
};
 
MultiCompiler.prototype.purgeInputFileSystem = function() {
	this.compilers.forEach(function(compiler) {
		if(compiler.inputFileSystem && compiler.inputFileSystem.purge)
			compiler.inputFileSystem.purge();
	});
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiEntryPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiEntryPlugin.js

Statements: 21.05% (4 / 19)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 21.05% (4 / 19)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41            1 1 1   1                                                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const MultiEntryDependency = require("./dependencies/MultiEntryDependency");
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
const MultiModuleFactory = require("./MultiModuleFactory");
 
module.exports = class MultiEntryPlugin {
	constructor(context, entries, name) {
		this.context = context;
		this.entries = entries;
		this.name = name;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const multiModuleFactory = new MultiModuleFactory();
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(MultiEntryDependency, multiModuleFactory);
			compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
		});
		compiler.plugin("make", (compilation, callback) => {
			const dep = MultiEntryPlugin.createDependency(this.entries, this.name);
			compilation.addEntry(this.context, dep, this.name, callback);
		});
	}
 
	static createDependency(entries, name) {
		return new MultiEntryDependency(entries.map((e, idx) => {
			const dep = new SingleEntryDependency(e);
			dep.loc = name + ":" + (100000 + idx);
			return dep;
		}), name);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiModule.js

Statements: 8.11% (3 / 37)      Branches: 0% (0 / 8)      Functions: 0% (0 / 10)      Lines: 8.57% (3 / 35)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77            1 1                                                                                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Module = require("./Module");
const RawSource = require("webpack-sources").RawSource;
 
class MultiModule extends Module {
 
	constructor(context, dependencies, name) {
		super();
		this.context = context;
		this.dependencies = dependencies;
		this.name = name;
		this.built = false;
		this.cacheable = true;
	}
 
	identifier() {
		return `multi ${this.dependencies.map((d) => d.request).join(" ")}`;
	}
 
	readableIdentifier(requestShortener) {
		return `multi ${this.dependencies.map((d) => requestShortener.shorten(d.request)).join(" ")}`;
	}
 
	disconnect() {
		this.built = false;
		super.disconnect();
	}
 
	build(options, compilation, resolver, fs, callback) {
		this.built = true;
		return callback();
	}
 
	needRebuild() {
		return false;
	}
 
	size() {
		return 16 + this.dependencies.length * 12;
	}
 
	updateHash(hash) {
		hash.update("multi module");
		hash.update(this.name || "");
		super.updateHash(hash);
	}
 
	source(dependencyTemplates, outputOptions) {
		const str = [];
		this.dependencies.forEach(function(dep, idx) {
			if(dep.module) {
				if(idx === this.dependencies.length - 1)
					str.push("module.exports = ");
				str.push("__webpack_require__(");
				if(outputOptions.pathinfo)
					str.push(`/*! ${dep.request} */`);
				str.push(`${JSON.stringify(dep.module.id)}`);
				str.push(")");
			} else {
				str.push("(function webpackMissingModule() { throw new Error(");
				str.push(JSON.stringify(`Cannot find module "${dep.request}"`));
				str.push("); }())");
			}
			str.push(";\n");
		}, this);
		return new RawSource(str.join(""));
	}
}
 
module.exports = MultiModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiModuleFactory.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiModuleFactory.js

Statements: 50% (3 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (3 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21            1 1   1                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Tapable = require("tapable");
const MultiModule = require("./MultiModule");
 
module.exports = class MultiModuleFactory extends Tapable {
	constructor() {
		super();
	}
 
	create(data, callback) {
		const dependency = data.dependencies[0];
		callback(null, new MultiModule(data.context, dependency.dependencies, dependency.name));
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiStats.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiStats.js

Statements: 6.25% (3 / 48)      Branches: 0% (0 / 32)      Functions: 0% (0 / 5)      Lines: 7.5% (3 / 40)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81            1   1                                                                                                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Stats = require("./Stats");
 
const optionOrFallback = (optionValue, fallbackValue) => optionValue !== undefined ? optionValue : fallbackValue;
 
class MultiStats {
	constructor(stats) {
		this.stats = stats;
		this.hash = stats.map(stat => stat.hash).join("");
	}
 
	hasErrors() {
		return this.stats.map((stat) => stat.hasErrors()).reduce((a, b) => a || b, false);
	}
 
	hasWarnings() {
		return this.stats.map((stat) => stat.hasWarnings()).reduce((a, b) => a || b, false);
	}
 
	toJson(options, forToString) {
		if(typeof options === "boolean" || typeof options === "string") {
			options = Stats.presetToOptions(options);
		} else if(!options) {
			options = {};
		}
		const jsons = this.stats.map((stat, idx) => {
			const childOptions = Stats.getChildOptions(options, idx);
			const obj = stat.toJson(childOptions, forToString);
			obj.name = stat.compilation && stat.compilation.name;
			return obj;
		});
		const showVersion = typeof options.version === "undefined" ? jsons.every(j => j.version) : options.version !== false;
		const showHash = typeof options.hash === "undefined" ? jsons.every(j => j.hash) : options.hash !== false;
		jsons.forEach(j => {
			if(showVersion)
				delete j.version;
		});
		const obj = {
			errors: jsons.reduce((arr, j) => {
				return arr.concat(j.errors.map(msg => {
					return `(${j.name}) ${msg}`;
				}));
			}, []),
			warnings: jsons.reduce((arr, j) => {
				return arr.concat(j.warnings.map(msg => {
					return `(${j.name}) ${msg}`;
				}));
			}, [])
		};
		if(showVersion)
			obj.version = require("../package.json").version;
		if(showHash)
			obj.hash = this.hash;
		if(options.children !== false)
			obj.children = jsons;
		return obj;
	}
 
	toString(options) {
		if(typeof options === "boolean" || typeof options === "string") {
			options = Stats.presetToOptions(options);
		} else if(!options) {
			options = {};
		}
 
		const useColors = optionOrFallback(options.colors, false);
 
		const obj = this.toJson(options, true);
 
		return Stats.jsonToString(obj, useColors);
	}
}
 
module.exports = MultiStats;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiWatching.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/MultiWatching.js

Statements: 16.67% (2 / 12)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 20% (2 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34            1                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const asyncLib = require("async");
 
class MultiWatching {
	constructor(watchings, compiler) {
		this.watchings = watchings;
		this.compiler = compiler;
	}
 
	invalidate() {
		this.watchings.forEach((watching) => watching.invalidate());
	}
 
	close(callback) {
		if(callback === undefined) callback = () => { /*do nothing*/ };
 
		asyncLib.forEach(this.watchings, (watching, finishedCallback) => {
			watching.close(finishedCallback);
		}, err => {
			this.compiler.applyPlugins("watch-close");
			callback(err);
		});
 
	}
}
 
module.exports = MultiWatching;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NamedChunksPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NamedChunksPlugin.js

Statements: 12.5% (1 / 8)      Branches: 0% (0 / 6)      Functions: 0% (0 / 3)      Lines: 12.5% (1 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                                                          1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class NamedChunksPlugin {
 
	static defaultNameResolver(chunk) {
		return chunk.name || null;
	}
 
	constructor(nameResolver) {
		this.nameResolver = nameResolver || NamedChunksPlugin.defaultNameResolver;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("before-chunk-ids", (chunks) => {
				chunks.forEach((chunk) => {
					if(chunk.id === null) {
						chunk.id = this.nameResolver(chunk);
					}
				});
			});
		});
	}
}
 
module.exports = NamedChunksPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NamedModulesPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NamedModulesPlugin.js

Statements: 14.29% (1 / 7)      Branches: 0% (0 / 8)      Functions: 0% (0 / 2)      Lines: 14.29% (1 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29                                                    1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class NamedModulesPlugin {
	constructor(options) {
		this.options = options || {};
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("before-module-ids", (modules) => {
				modules.forEach((module) => {
					if(module.id === null && module.libIdent) {
						module.id = module.libIdent({
							context: this.options.context || compiler.options.context
						});
					}
				});
			});
		});
	}
}
 
module.exports = NamedModulesPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NewWatchingPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NewWatchingPlugin.js

Statements: 33.33% (1 / 3)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 33.33% (1 / 3)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                            1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class NewWatchingPlugin {
	apply(compiler) {
		compiler.plugin("compilation", function(compilation) {
			compilation.warnings.push(new Error("The 'NewWatchingPlugin' is no longer necessary (now default)"));
		});
	}
}
 
module.exports = NewWatchingPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NoEmitOnErrorsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NoEmitOnErrorsPlugin.js

Statements: 12.5% (1 / 8)      Branches: 0% (0 / 4)      Functions: 0% (0 / 1)      Lines: 12.5% (1 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                                          1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class NoEmitOnErrorsPlugin {
	apply(compiler) {
		compiler.plugin("should-emit", (compilation) => {
			if(compilation.errors.length > 0)
				return false;
		});
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("should-record", () => {
				if(compilation.errors.length > 0)
					return false;
			});
		});
	}
}
 
module.exports = NoEmitOnErrorsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NoErrorsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NoErrorsPlugin.js

Statements: 16.67% (2 / 12)      Branches: 0% (0 / 6)      Functions: 0% (0 / 1)      Lines: 16.67% (2 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31            1                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
let deprecationReported = false;
 
class NoErrorsPlugin {
	apply(compiler) {
		compiler.plugin("should-emit", (compilation) => {
			if(!deprecationReported) {
				compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" +
					"Use NoEmitOnErrorsPlugin instead.\n");
				deprecationReported = true;
			}
			if(compilation.errors.length > 0)
				return false;
		});
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("should-record", () => {
				if(compilation.errors.length > 0)
					return false;
			});
		});
	}
}
 
module.exports = NoErrorsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NodeStuffPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NodeStuffPlugin.js

Statements: 10.94% (7 / 64)      Branches: 0% (0 / 30)      Functions: 0% (0 / 10)      Lines: 11.67% (7 / 60)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99            1 1 1   1                                           1             1                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
const ParserHelpers = require("./ParserHelpers");
const ConstDependency = require("./dependencies/ConstDependency");
 
const NullFactory = require("./NullFactory");
 
class NodeStuffPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(parserOptions.node === false)
					return;
 
				let localOptions = options;
				if(parserOptions.node)
					localOptions = Object.assign({}, localOptions, parserOptions.node);
 
				function setConstant(expressionName, value) {
					parser.plugin(`expression ${expressionName}`, function() {
						this.state.current.addVariable(expressionName, JSON.stringify(value));
						return true;
					});
				}
 
				function setModuleConstant(expressionName, fn) {
					parser.plugin(`expression ${expressionName}`, function() {
						this.state.current.addVariable(expressionName, JSON.stringify(fn(this.state.module)));
						return true;
					});
				}
				const context = compiler.context;
				if(localOptions.__filename === "mock") {
					setConstant("__filename", "/index.js");
				} else if(localOptions.__filename) {
					setModuleConstant("__filename", module => path.relative(context, module.resource));
				}
				parser.plugin("evaluate Identifier __filename", function(expr) {
					if(!this.state.module) return;
					const resource = this.state.module.resource;
					const i = resource.indexOf("?");
					return ParserHelpers.evaluateToString(i < 0 ? resource : resource.substr(0, i))(expr);
				});
				if(localOptions.__dirname === "mock") {
					setConstant("__dirname", "/");
				} else if(localOptions.__dirname) {
					setModuleConstant("__dirname", module => path.relative(context, module.context));
				}
				parser.plugin("evaluate Identifier __dirname", function(expr) {
					if(!this.state.module) return;
					return ParserHelpers.evaluateToString(this.state.module.context)(expr);
				});
				parser.plugin("expression require.main", ParserHelpers.toConstantDependency("__webpack_require__.c[__webpack_require__.s]"));
				parser.plugin(
					"expression require.extensions",
					ParserHelpers.expressionIsUnsupported("require.extensions is not supported by webpack. Use a loader instead.")
				);
				parser.plugin("expression module.loaded", ParserHelpers.toConstantDependency("module.l"));
				parser.plugin("expression module.id", ParserHelpers.toConstantDependency("module.i"));
				parser.plugin("expression module.exports", function() {
					const module = this.state.module;
					const isHarmony = module.meta && module.meta.harmonyModule;
					if(!isHarmony)
						return true;
				});
				parser.plugin("evaluate Identifier module.hot", ParserHelpers.evaluateToBoolean(false));
				parser.plugin("expression module", function() {
					const module = this.state.module;
					const isHarmony = module.meta && module.meta.harmonyModule;
					let moduleJsPath = path.join(__dirname, "..", "buildin", isHarmony ? "harmony-module.js" : "module.js");
					if(module.context) {
						moduleJsPath = path.relative(this.state.module.context, moduleJsPath);
						if(!/^[A-Z]:/i.test(moduleJsPath)) {
							moduleJsPath = `./${moduleJsPath.replace(/\\/g, "/")}`;
						}
					}
					return ParserHelpers.addParsedVariableToModule(this, "module", `require(${JSON.stringify(moduleJsPath)})(module)`);
				});
			});
		});
	}
}
module.exports = NodeStuffPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NormalModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NormalModule.js

Statements: 8.3% (20 / 241)      Branches: 0% (0 / 88)      Functions: 0% (0 / 36)      Lines: 8.77% (20 / 228)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526            1 1 1   1 1 1 1 1 1   1 1 1 1 1 1   1 1   1             1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
const NativeModule = require("module");
const crypto = require("crypto");
 
const SourceMapSource = require("webpack-sources").SourceMapSource;
const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
const ReplaceSource = require("webpack-sources").ReplaceSource;
const CachedSource = require("webpack-sources").CachedSource;
const LineToLineMappedSource = require("webpack-sources").LineToLineMappedSource;
 
const WebpackError = require("./WebpackError");
const Module = require("./Module");
const ModuleParseError = require("./ModuleParseError");
const ModuleBuildError = require("./ModuleBuildError");
const ModuleError = require("./ModuleError");
const ModuleWarning = require("./ModuleWarning");
 
const runLoaders = require("loader-runner").runLoaders;
const getContext = require("loader-runner").getContext;
 
function asString(buf) {
	if(Buffer.isBuffer(buf)) {
		return buf.toString("utf-8");
	}
	return buf;
}
 
function contextify(context, request) {
	return request.split("!").map(function(r) {
		let rp = path.relative(context, r);
		if(path.sep === "\\")
			rp = rp.replace(/\\/g, "/");
		if(rp.indexOf("../") !== 0)
			rp = "./" + rp;
		return rp;
	}).join("!");
}
 
class NonErrorEmittedError extends WebpackError {
	constructor(error) {
		super();
 
		this.name = "NonErrorEmittedError";
		this.message = "(Emitted value instead of an instance of Error) " + error;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
class NormalModule extends Module {
 
	constructor(request, userRequest, rawRequest, loaders, resource, parser) {
		super();
		this.request = request;
		this.userRequest = userRequest;
		this.rawRequest = rawRequest;
		this.parser = parser;
		this.resource = resource;
		this.context = getContext(resource);
		this.loaders = loaders;
		this.fileDependencies = [];
		this.contextDependencies = [];
		this.warnings = [];
		this.errors = [];
		this.error = null;
		this._source = null;
		this.assets = {};
		this.built = false;
		this._cachedSource = null;
	}
 
	identifier() {
		return this.request;
	}
 
	readableIdentifier(requestShortener) {
		return requestShortener.shorten(this.userRequest);
	}
 
	libIdent(options) {
		return contextify(options.context, this.userRequest);
	}
 
	nameForCondition() {
		const idx = this.resource.indexOf("?");
		if(idx >= 0) return this.resource.substr(0, idx);
		return this.resource;
	}
 
	createSourceForAsset(name, content, sourceMap) {
		if(!sourceMap) {
			return new RawSource(content);
		}
 
		if(typeof sourceMap === "string") {
			return new OriginalSource(content, sourceMap);
		}
 
		return new SourceMapSource(content, name, sourceMap);
	}
 
	createLoaderContext(resolver, options, compilation, fs) {
		const loaderContext = {
			version: 2,
			emitWarning: (warning) => {
				if(!(warning instanceof Error))
					warning = new NonErrorEmittedError(warning);
				this.warnings.push(new ModuleWarning(this, warning));
			},
			emitError: (error) => {
				if(!(error instanceof Error))
					error = new NonErrorEmittedError(error);
				this.errors.push(new ModuleError(this, error));
			},
			exec: (code, filename) => {
				const module = new NativeModule(filename, this);
				module.paths = NativeModule._nodeModulePaths(this.context);
				module.filename = filename;
				module._compile(code, filename);
				return module.exports;
			},
			resolve(context, request, callback) {
				resolver.resolve({}, context, request, callback);
			},
			resolveSync(context, request) {
				return resolver.resolveSync({}, context, request);
			},
			emitFile: (name, content, sourceMap) => {
				this.assets[name] = this.createSourceForAsset(name, content, sourceMap);
			},
			options: options,
			webpack: true,
			sourceMap: !!this.useSourceMap,
			_module: this,
			_compilation: compilation,
			_compiler: compilation.compiler,
			fs: fs,
		};
 
		compilation.applyPlugins("normal-module-loader", loaderContext, this);
		if(options.loader)
			Object.assign(loaderContext, options.loader);
 
		return loaderContext;
	}
 
	createSource(source, resourceBuffer, sourceMap) {
		// if there is no identifier return raw source
		if(!this.identifier) {
			return new RawSource(source);
		}
 
		// from here on we assume we have an identifier
		const identifier = this.identifier();
 
		if(this.lineToLine && resourceBuffer) {
			return new LineToLineMappedSource(
				source, identifier, asString(resourceBuffer));
		}
 
		if(this.useSourceMap && sourceMap) {
			return new SourceMapSource(source, identifier, sourceMap);
		}
 
		return new OriginalSource(source, identifier);
	}
 
	doBuild(options, compilation, resolver, fs, callback) {
		this.cacheable = false;
		const loaderContext = this.createLoaderContext(resolver, options, compilation, fs);
 
		runLoaders({
			resource: this.resource,
			loaders: this.loaders,
			context: loaderContext,
			readResource: fs.readFile.bind(fs)
		}, (err, result) => {
			if(result) {
				this.cacheable = result.cacheable;
				this.fileDependencies = result.fileDependencies;
				this.contextDependencies = result.contextDependencies;
			}
 
			if(err) {
				const error = new ModuleBuildError(this, err);
				return callback(error);
			}
 
			const resourceBuffer = result.resourceBuffer;
			const source = result.result[0];
			const sourceMap = result.result[1];
 
			if(!Buffer.isBuffer(source) && typeof source !== "string") {
				const error = new ModuleBuildError(this, new Error("Final loader didn't return a Buffer or String"));
				return callback(error);
			}
 
			this._source = this.createSource(asString(source), resourceBuffer, sourceMap);
			return callback();
		});
	}
 
	disconnect() {
		this.built = false;
		super.disconnect();
	}
 
	markModuleAsErrored(error) {
		this.meta = null;
		this.error = error;
		this.errors.push(this.error);
		this._source = new RawSource("throw new Error(" + JSON.stringify(this.error.message) + ");");
	}
 
	applyNoParseRule(rule, content) {
		// must start with "rule" if rule is a string
		if(typeof rule === "string") {
			return content.indexOf(rule) === 0;
		}
		// we assume rule is a regexp
		return rule.test(content);
	}
 
	// check if module should not be parsed
	// returns "true" if the module should !not! be parsed
	// returns "false" if the module !must! be parsed
	shouldPreventParsing(noParseRule, request) {
		// if no noParseRule exists, return false
		// the module !must! be parsed.
		if(!noParseRule) {
			return false;
		}
 
		// we only have one rule to check
		if(!Array.isArray(noParseRule)) {
			// returns "true" if the module is !not! to be parsed
			return this.applyNoParseRule(noParseRule, request);
		}
 
		for(let i = 0; i < noParseRule.length; i++) {
			const rule = noParseRule[i];
			// early exit on first truthy match
			// this module is !not! to be parsed
			if(this.applyNoParseRule(rule, request)) {
				return true;
			}
		}
		// no match found, so this module !should! be parsed
		return false;
	}
 
	build(options, compilation, resolver, fs, callback) {
		this.buildTimestamp = new Date().getTime();
		this.built = true;
		this._source = null;
		this.error = null;
		this.errors.length = 0;
		this.warnings.length = 0;
		this.meta = {};
 
		return this.doBuild(options, compilation, resolver, fs, (err) => {
			this.dependencies.length = 0;
			this.variables.length = 0;
			this.blocks.length = 0;
			this._cachedSource = null;
 
			// if we have an error mark module as failed and exit
			if(err) {
				this.markModuleAsErrored(err);
				return callback();
			}
 
			// check if this module should !not! be parsed.
			// if so, exit here;
			const noParseRule = options.module && options.module.noParse;
			if(this.shouldPreventParsing(noParseRule, this.request)) {
				return callback();
			}
 
			try {
				this.parser.parse(this._source.source(), {
					current: this,
					module: this,
					compilation: compilation,
					options: options
				});
			} catch(e) {
				const source = this._source.source();
				const error = new ModuleParseError(this, source, e);
				this.markModuleAsErrored(error);
				return callback();
			}
			return callback();
		});
	}
 
	getHashDigest() {
		const hash = crypto.createHash("md5");
		this.updateHash(hash);
		return hash.digest("hex");
	}
 
	sourceDependency(dependency, dependencyTemplates, source, outputOptions, requestShortener) {
		const template = dependencyTemplates.get(dependency.constructor);
		if(!template) throw new Error("No template for dependency: " + dependency.constructor.name);
		template.apply(dependency, source, outputOptions, requestShortener, dependencyTemplates);
	}
 
	sourceVariables(variable, availableVars, dependencyTemplates, outputOptions, requestShortener) {
		const name = variable.name;
		const expr = variable.expressionSource(dependencyTemplates, outputOptions, requestShortener);
 
		if(availableVars.some(v => v.name === name && v.expression.source() === expr.source())) {
			return;
		}
		return {
			name: name,
			expression: expr
		};
	}
 
	/*
	 * creates the start part of a IIFE around the module to inject a variable name
	 * (function(...){   <- this part
	 * }.call(...))
	 */
	variableInjectionFunctionWrapperStartCode(varNames) {
		const args = varNames.join(", ");
		return `/* WEBPACK VAR INJECTION */(function(${args}) {`;
	}
 
	contextArgument(block) {
		if(this === block) {
			return this.exportsArgument || "exports";
		}
		return "this";
	}
 
	/*
	 * creates the end part of a IIFE around the module to inject a variable name
	 * (function(...){
	 * }.call(...))   <- this part
	 */
	variableInjectionFunctionWrapperEndCode(varExpressions, block) {
		const firstParam = this.contextArgument(block);
		const furtherParams = varExpressions.map(e => e.source()).join(", ");
		return `}.call(${firstParam}, ${furtherParams}))`;
	}
 
	splitVariablesInUniqueNamedChunks(vars) {
		const startState = [
			[]
		];
		return vars.reduce((chunks, variable) => {
			const current = chunks[chunks.length - 1];
			// check if variable with same name exists already
			// if so create a new chunk of variables.
			const variableNameAlreadyExists = current.some(v => v.name === variable.name);
 
			if(variableNameAlreadyExists) {
				// start new chunk with current variable
				chunks.push([variable]);
			} else {
				// else add it to current chunk
				current.push(variable);
			}
			return chunks;
		}, startState);
	}
 
	sourceBlock(block, availableVars, dependencyTemplates, source, outputOptions, requestShortener) {
		block.dependencies.forEach((dependency) => this.sourceDependency(
			dependency, dependencyTemplates, source, outputOptions, requestShortener));
 
		/**
		 * Get the variables of all blocks that we need to inject.
		 * These will contain the variable name and its expression.
		 * The name will be added as a paramter in a IIFE the expression as its value.
		 */
		const vars = block.variables.map((variable) => this.sourceVariables(
				variable, availableVars, dependencyTemplates, outputOptions, requestShortener))
			.filter(Boolean);
 
		/**
		 * if we actually have variables
		 * this is important as how #splitVariablesInUniqueNamedChunks works
		 * it will always return an array in an array which would lead to a IIFE wrapper around
		 * a module if we do this with an empty vars array.
		 */
		if(vars.length > 0) {
			/**
			 * Split all variables up into chunks of unique names.
			 * e.g. imagine you have the following variable names that need to be injected:
			 * [foo, bar, baz, foo, some, more]
			 * we can not inject "foo" twice, therefore we just make two IIFEs like so:
			 * (function(foo, bar, baz){
			 *   (function(foo, some, more){
			 *     ...
			 *   }(...));
			 * }(...));
			 *
			 * "splitVariablesInUniqueNamedChunks" splits the variables shown above up to this:
			 * [[foo, bar, baz], [foo, some, more]]
			 */
			const injectionVariableChunks = this.splitVariablesInUniqueNamedChunks(vars);
 
			// create all the beginnings of IIFEs
			const functionWrapperStarts = injectionVariableChunks.map((variableChunk) => variableChunk.map(variable => variable.name))
				.map(names => this.variableInjectionFunctionWrapperStartCode(names));
 
			// and all the ends
			const functionWrapperEnds = injectionVariableChunks.map((variableChunk) => variableChunk.map(variable => variable.expression))
				.map(expressions => this.variableInjectionFunctionWrapperEndCode(expressions, block));
 
			// join them to one big string
			const varStartCode = functionWrapperStarts.join("");
			// reverse the ends first before joining them, as the last added must be the inner most
			const varEndCode = functionWrapperEnds.reverse().join("");
 
			// if we have anything, add it to the source
			if(varStartCode && varEndCode) {
				const start = block.range ? block.range[0] : -10;
				const end = block.range ? block.range[1] : (this._source.size() + 1);
				source.insert(start + 0.5, varStartCode);
				source.insert(end + 0.5, "\n/* WEBPACK VAR INJECTION */" + varEndCode);
			}
		}
		block.blocks.forEach((block) => this.sourceBlock(
			block, availableVars.concat(vars), dependencyTemplates, source, outputOptions, requestShortener));
	}
 
	source(dependencyTemplates, outputOptions, requestShortener) {
		const hashDigest = this.getHashDigest();
		if(this._cachedSource && this._cachedSource.hash === hashDigest) {
			return this._cachedSource.source;
		}
 
		if(!this._source) {
			return new RawSource("throw new Error('No source available');");
		}
 
		const source = new ReplaceSource(this._source);
		this._cachedSource = {
			source: source,
			hash: hashDigest
		};
 
		this.sourceBlock(this, [], dependencyTemplates, source, outputOptions, requestShortener);
		return new CachedSource(source);
	}
 
	originalSource() {
		return this._source;
	}
 
	getHighestTimestamp(keys, timestampsByKey) {
		let highestTimestamp = 0;
		for(let i = 0; i < keys.length; i++) {
			const key = keys[i];
			const timestamp = timestampsByKey[key];
			// if there is no timestamp yet, early return with Infinity
			if(!timestamp) return Infinity;
			highestTimestamp = Math.max(highestTimestamp, timestamp);
		}
		return highestTimestamp;
	}
 
	needRebuild(fileTimestamps, contextTimestamps) {
		const highestFileDepTimestamp = this.getHighestTimestamp(
			this.fileDependencies, fileTimestamps);
		// if the hightest is Infinity, we need a rebuild
		// exit early here.
		if(highestFileDepTimestamp === Infinity) {
			return true;
		}
 
		const highestContextDepTimestamp = this.getHighestTimestamp(
			this.contextDependencies, contextTimestamps);
 
		// Again if the hightest is Infinity, we need a rebuild
		// exit early here.
		if(highestContextDepTimestamp === Infinity) {
			return true;
		}
 
		// else take the highest of file and context timestamps and compare
		// to last build timestamp
		return Math.max(highestContextDepTimestamp, highestFileDepTimestamp) >= this.buildTimestamp;
	}
 
	size() {
		return this._source ? this._source.size() : -1;
	}
 
	updateHashWithSource(hash) {
		if(!this._source) {
			hash.update("null");
			return;
		}
		hash.update("source");
		this._source.updateHash(hash);
	}
 
	updateHashWithMeta(hash) {
		hash.update("meta");
		hash.update(JSON.stringify(this.meta));
	}
 
	updateHash(hash) {
		this.updateHashWithSource(hash);
		this.updateHashWithMeta(hash);
		super.updateHash(hash);
	}
 
}
 
module.exports = NormalModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NormalModuleFactory.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NormalModuleFactory.js

Statements: 5.63% (9 / 160)      Branches: 0% (0 / 105)      Functions: 0% (0 / 9)      Lines: 6.25% (9 / 144)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306            1 1 1 1 1 1   1                       1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1    
/*
 MIT License http://www.opensource.org/licenses/mit-license.php
 Author Tobias Koppers @sokra
 */
"use strict";
 
const asyncLib = require("async");
const Tapable = require("tapable");
const NormalModule = require("./NormalModule");
const RawModule = require("./RawModule");
const Parser = require("./Parser");
const RuleSet = require("./RuleSet");
 
function loaderToIdent(data) {
	if(!data.options)
		return data.loader;
	if(typeof data.options === "string")
		return data.loader + "?" + data.options;
	if(typeof data.options !== "object")
		throw new Error("loader options must be string or object");
	if(data.ident)
		return data.loader + "??" + data.ident;
	return data.loader + "?" + JSON.stringify(data.options);
}
 
function identToLoaderRequest(resultString) {
	const idx = resultString.indexOf("?");
	let options;
 
	if(idx >= 0) {
		options = resultString.substr(idx + 1);
		resultString = resultString.substr(0, idx);
 
		return {
			loader: resultString,
			options
		};
	} else {
		return {
			loader: resultString
		};
	}
}
 
class NormalModuleFactory extends Tapable {
	constructor(context, resolvers, options) {
		super();
		this.resolvers = resolvers;
		this.ruleSet = new RuleSet(options.rules || options.loaders);
		this.cachePredicate = typeof options.unsafeCache === "function" ? options.unsafeCache : Boolean.bind(null, options.unsafeCache);
		this.context = context || "";
		this.parserCache = {};
		this.plugin("factory", function() {
			/* beautify preserve:start */
            // js-beautify consider to concat "return" and "("
            // but it сontradicts eslint rule (keyword-spacing)
			return (result, callback) => {
				/* beautify preserve:end */
				let resolver = this.applyPluginsWaterfall0("resolver", null);
 
				// Ignored
				if(!resolver) return callback();
 
				resolver(result, (err, data) => {
					if(err) return callback(err);
 
					// Ignored
					if(!data) return callback();
 
					// direct module
					if(typeof data.source === "function")
						return callback(null, data);
 
					this.applyPluginsAsyncWaterfall("after-resolve", data, (err, result) => {
						if(err) return callback(err);
 
						// Ignored
						if(!result) return callback();
 
						let createdModule = this.applyPluginsBailResult("create-module", result);
						if(!createdModule) {
 
							if(!result.request) {
								return callback(new Error("Empty dependency (no request)"));
							}
 
							createdModule = new NormalModule(
								result.request,
								result.userRequest,
								result.rawRequest,
								result.loaders,
								result.resource,
								result.parser
							);
						}
 
						createdModule = this.applyPluginsWaterfall0("module", createdModule);
 
						return callback(null, createdModule);
					});
				});
			};
		});
		this.plugin("resolver", function() {
			/* beautify preserve:start */
            // js-beautify consider to concat "return" and "("
            // but it сontradicts eslint rule (keyword-spacing)
			return (data, callback) => {
				/* beautify preserve:end */
				const contextInfo = data.contextInfo;
				const context = data.context;
				const request = data.request;
 
				const noAutoLoaders = /^-?!/.test(request);
				const noPrePostAutoLoaders = /^!!/.test(request);
				const noPostAutoLoaders = /^-!/.test(request);
				let elements = request.replace(/^-?!+/, "").replace(/!!+/g, "!").split("!");
				let resource = elements.pop();
				elements = elements.map(identToLoaderRequest);
 
				asyncLib.parallel([
					callback => this.resolveRequestArray(contextInfo, context, elements, this.resolvers.loader, callback),
					callback => {
						if(resource === "" || resource[0] === "?")
							return callback(null, {
								resource
							});
 
						this.resolvers.normal.resolve(contextInfo, context, resource, (err, resource, resourceResolveData) => {
							if(err) return callback(err);
							callback(null, {
								resourceResolveData,
								resource
							});
						});
					}
				], (err, results) => {
					if(err) return callback(err);
					let loaders = results[0];
					const resourceResolveData = results[1].resourceResolveData;
					resource = results[1].resource;
 
					// translate option idents
					try {
						loaders.forEach(item => {
							if(typeof item.options === "string" && /^\?/.test(item.options)) {
								item.options = this.ruleSet.findOptionsByIdent(item.options.substr(1));
							}
						});
					} catch(e) {
						return callback(e);
					}
 
					if(resource === false) {
						// ignored
						return callback(null,
							new RawModule(
								"/* (ignored) */",
								`ignored ${context} ${request}`,
								`${request} (ignored)`
							)
						);
					}
 
					const userRequest = loaders.map(loaderToIdent).concat([resource]).join("!");
 
					let resourcePath = resource;
					let resourceQuery = "";
					const queryIndex = resourcePath.indexOf("?");
					if(queryIndex >= 0) {
						resourceQuery = resourcePath.substr(queryIndex);
						resourcePath = resourcePath.substr(0, queryIndex);
					}
 
					const result = this.ruleSet.exec({
						resource: resourcePath,
						resourceQuery,
						issuer: contextInfo.issuer,
						compiler: contextInfo.compiler
					});
					const settings = {};
					const useLoadersPost = [];
					const useLoaders = [];
					const useLoadersPre = [];
					result.forEach(r => {
						if(r.type === "use") {
							if(r.enforce === "post" && !noPostAutoLoaders && !noPrePostAutoLoaders)
								useLoadersPost.push(r.value);
							else if(r.enforce === "pre" && !noPrePostAutoLoaders)
								useLoadersPre.push(r.value);
							else if(!r.enforce && !noAutoLoaders && !noPrePostAutoLoaders)
								useLoaders.push(r.value);
						} else {
							settings[r.type] = r.value;
						}
					});
					asyncLib.parallel([
						this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPost, this.resolvers.loader),
						this.resolveRequestArray.bind(this, contextInfo, this.context, useLoaders, this.resolvers.loader),
						this.resolveRequestArray.bind(this, contextInfo, this.context, useLoadersPre, this.resolvers.loader)
					], (err, results) => {
						if(err) return callback(err);
						loaders = results[0].concat(loaders, results[1], results[2]);
						process.nextTick(() => {
							callback(null, {
								context: context,
								request: loaders.map(loaderToIdent).concat([resource]).join("!"),
								dependencies: data.dependencies,
								userRequest,
								rawRequest: request,
								loaders,
								resource,
								resourceResolveData,
								parser: this.getParser(settings.parser)
							});
						});
					});
				});
			};
		});
	}
 
	create(data, callback) {
		const dependencies = data.dependencies;
		const cacheEntry = dependencies[0].__NormalModuleFactoryCache;
		if(cacheEntry) return callback(null, cacheEntry);
		const context = data.context || this.context;
		const request = dependencies[0].request;
		const contextInfo = data.contextInfo || {};
		this.applyPluginsAsyncWaterfall("before-resolve", {
			contextInfo,
			context,
			request,
			dependencies
		}, (err, result) => {
			if(err) return callback(err);
 
			// Ignored
			if(!result) return callback();
 
			const factory = this.applyPluginsWaterfall0("factory", null);
 
			// Ignored
			if(!factory) return callback();
 
			factory(result, (err, module) => {
				if(err) return callback(err);
 
				if(module && this.cachePredicate(module)) {
					dependencies.forEach(d => d.__NormalModuleFactoryCache = module);
				}
 
				callback(null, module);
			});
		});
	}
 
	resolveRequestArray(contextInfo, context, array, resolver, callback) {
		if(array.length === 0) return callback(null, []);
		asyncLib.map(array, (item, callback) => {
			resolver.resolve(contextInfo, context, item.loader, (err, result) => {
				if(err && /^[^/]*$/.test(item.loader) && !/-loader$/.test(item.loader)) {
					return resolver.resolve(contextInfo, context, item.loader + "-loader", err2 => {
						if(!err2) {
							err.message = err.message + "\n" +
								"BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n" +
								`                 You need to specify '${item.loader}-loader' instead of '${item.loader}',\n` +
								"                 see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed";
						}
						callback(err);
					});
				}
				if(err) return callback(err);
 
				const optionsOnly = item.options ? {
					options: item.options
				} : undefined;
				return callback(null, Object.assign({}, item, identToLoaderRequest(result), optionsOnly));
			});
		}, callback);
	}
 
	getParser(parserOptions) {
		let ident = "null";
		if(parserOptions) {
			if(parserOptions.ident)
				ident = parserOptions.ident;
			else
				ident = JSON.stringify(parserOptions);
		}
		const parser = this.parserCache[ident];
		if(parser)
			return parser;
		return this.parserCache[ident] = this.createParser(parserOptions);
	}
 
	createParser(parserOptions) {
		const parser = new Parser();
		this.applyPlugins2("parser", parser, parserOptions || {});
		return parser;
	}
}
 
module.exports = NormalModuleFactory;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NormalModuleReplacementPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NormalModuleReplacementPlugin.js

Statements: 8.7% (2 / 23)      Branches: 0% (0 / 12)      Functions: 0% (0 / 2)      Lines: 9.52% (2 / 21)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » NormalModuleReplacementPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47            1                                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
 
class NormalModuleReplacementPlugin {
	constructor(resourceRegExp, newResource) {
		this.resourceRegExp = resourceRegExp;
		this.newResource = newResource;
	}
 
	apply(compiler) {
		const resourceRegExp = this.resourceRegExp;
		const newResource = this.newResource;
		compiler.plugin("normal-module-factory", (nmf) => {
			nmf.plugin("before-resolve", (result, callback) => {
				if(!result) return callback();
				if(resourceRegExp.test(result.request)) {
					if(typeof newResource === "function") {
						newResource(result);
					} else {
						result.request = newResource;
					}
				}
				return callback(null, result);
			});
			nmf.plugin("after-resolve", (result, callback) => {
				if(!result) return callback();
				if(resourceRegExp.test(result.resource)) {
					if(typeof newResource === "function") {
						newResource(result);
					} else {
						result.resource = path.resolve(path.dirname(result.resource), newResource);
					}
				}
				return callback(null, result);
			});
		});
	}
}
 
module.exports = NormalModuleReplacementPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NullFactory.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/NullFactory.js

Statements: 50% (1 / 2)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 50% (1 / 2)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14                      1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class NullFactory {
	create(data, callback) {
		return callback();
	}
}
module.exports = NullFactory;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/OptionsApply.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/OptionsApply.js

Statements: 100% (1 / 1)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 100% (1 / 1)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12                  1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class OptionsApply {
	process(options, compiler) {}
}
module.exports = OptionsApply;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/OptionsDefaulter.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/OptionsDefaulter.js

Statements: 7.32% (3 / 41)      Branches: 0% (0 / 23)      Functions: 0% (0 / 5)      Lines: 8.11% (3 / 37)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73            1                 1                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
function getProperty(obj, name) {
	name = name.split(".");
	for(var i = 0; i < name.length - 1; i++) {
		obj = obj[name[i]];
		if(typeof obj !== "object" || !obj) return;
	}
	return obj[name.pop()];
}
 
function setProperty(obj, name, value) {
	name = name.split(".");
	for(var i = 0; i < name.length - 1; i++) {
		if(typeof obj[name[i]] !== "object" && typeof obj[name[i]] !== "undefined") return;
		if(!obj[name[i]]) obj[name[i]] = {};
		obj = obj[name[i]];
	}
	obj[name.pop()] = value;
}
 
class OptionsDefaulter {
	constructor() {
		this.defaults = {};
		this.config = {};
	}
 
	process(options) {
		for(let name in this.defaults) {
			switch(this.config[name]) {
				case undefined:
					if(getProperty(options, name) === undefined)
						setProperty(options, name, this.defaults[name]);
					break;
				case "call":
					setProperty(options, name, this.defaults[name].call(this, getProperty(options, name), options), options);
					break;
				case "make":
					if(getProperty(options, name) === undefined)
						setProperty(options, name, this.defaults[name].call(this, options), options);
					break;
				case "append":
					{
						let oldValue = getProperty(options, name);
						if(!Array.isArray(oldValue)) oldValue = [];
						oldValue.push.apply(oldValue, this.defaults[name]);
						setProperty(options, name, oldValue);
						break;
					}
				default:
					throw new Error("OptionsDefaulter cannot process " + this.config[name]);
			}
		}
	}
 
	set(name, config, def) {
		if(arguments.length === 3) {
			this.defaults[name] = def;
			this.config[name] = config;
		} else {
			this.defaults[name] = config;
			delete this.config[name];
		}
	}
}
 
module.exports = OptionsDefaulter;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Parser.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Parser.js

Statements: 1.09% (9 / 823)      Branches: 0% (0 / 623)      Functions: 0% (0 / 124)      Lines: 1.17% (9 / 772)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393                1 1 1 1   1           1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
 
const acorn = require("acorn-dynamic-import").default;
const Tapable = require("tapable");
const json5 = require("json5");
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
 
function joinRanges(startRange, endRange) {
	if(!endRange) return startRange;
	if(!startRange) return endRange;
	return [startRange[0], endRange[1]];
}
 
const POSSIBLE_AST_OPTIONS = [{
	ranges: true,
	locations: true,
	ecmaVersion: 2017,
	sourceType: "module",
	plugins: {
		dynamicImport: true
	}
}, {
	ranges: true,
	locations: true,
	ecmaVersion: 2017,
	sourceType: "script",
	plugins: {
		dynamicImport: true
	}
}];
 
class Parser extends Tapable {
	constructor(options) {
		super();
		this.options = options;
		this.scope = undefined;
		this.state = undefined;
		this.comments = undefined;
		this.initializeEvaluating();
	}
 
	initializeEvaluating() {
		this.plugin("evaluate Literal", expr => {
			switch(typeof expr.value) {
				case "number":
					return new BasicEvaluatedExpression().setNumber(expr.value).setRange(expr.range);
				case "string":
					return new BasicEvaluatedExpression().setString(expr.value).setRange(expr.range);
				case "boolean":
					return new BasicEvaluatedExpression().setBoolean(expr.value).setRange(expr.range);
			}
			if(expr.value === null)
				return new BasicEvaluatedExpression().setNull().setRange(expr.range);
			if(expr.value instanceof RegExp)
				return new BasicEvaluatedExpression().setRegExp(expr.value).setRange(expr.range);
		});
		this.plugin("evaluate LogicalExpression", function(expr) {
			let left;
			let leftAsBool;
			let right;
			if(expr.operator === "&&") {
				left = this.evaluateExpression(expr.left);
				leftAsBool = left && left.asBool();
				if(leftAsBool === false) return left.setRange(expr.range);
				if(leftAsBool !== true) return;
				right = this.evaluateExpression(expr.right);
				return right.setRange(expr.range);
			} else if(expr.operator === "||") {
				left = this.evaluateExpression(expr.left);
				leftAsBool = left && left.asBool();
				if(leftAsBool === true) return left.setRange(expr.range);
				if(leftAsBool !== false) return;
				right = this.evaluateExpression(expr.right);
				return right.setRange(expr.range);
			}
		});
		this.plugin("evaluate BinaryExpression", function(expr) {
			let left;
			let right;
			let res;
			if(expr.operator === "+") {
				left = this.evaluateExpression(expr.left);
				right = this.evaluateExpression(expr.right);
				if(!left || !right) return;
				res = new BasicEvaluatedExpression();
				if(left.isString()) {
					if(right.isString()) {
						res.setString(left.string + right.string);
					} else if(right.isNumber()) {
						res.setString(left.string + right.number);
					} else if(right.isWrapped() && right.prefix && right.prefix.isString()) {
						res.setWrapped(
							new BasicEvaluatedExpression()
							.setString(left.string + right.prefix.string)
							.setRange(joinRanges(left.range, right.prefix.range)),
							right.postfix);
					} else if(right.isWrapped()) {
						res.setWrapped(
							new BasicEvaluatedExpression()
							.setString(left.string)
							.setRange(left.range),
							right.postfix);
					} else {
						res.setWrapped(left, null);
					}
				} else if(left.isNumber()) {
					if(right.isString()) {
						res.setString(left.number + right.string);
					} else if(right.isNumber()) {
						res.setNumber(left.number + right.number);
					}
				} else if(left.isWrapped()) {
					if(left.postfix && left.postfix.isString() && right.isString()) {
						res.setWrapped(left.prefix,
							new BasicEvaluatedExpression()
							.setString(left.postfix.string + right.string)
							.setRange(joinRanges(left.postfix.range, right.range))
						);
					} else if(left.postfix && left.postfix.isString() && right.isNumber()) {
						res.setWrapped(left.prefix,
							new BasicEvaluatedExpression()
							.setString(left.postfix.string + right.number)
							.setRange(joinRanges(left.postfix.range, right.range))
						);
					} else if(right.isString()) {
						res.setWrapped(left.prefix, right);
					} else if(right.isNumber()) {
						res.setWrapped(left.prefix,
							new BasicEvaluatedExpression()
							.setString(right.number + "")
							.setRange(right.range));
					} else {
						res.setWrapped(left.prefix, new BasicEvaluatedExpression());
					}
				} else {
					if(right.isString()) {
						res.setWrapped(null, right);
					}
				}
				res.setRange(expr.range);
				return res;
			} else if(expr.operator === "-") {
				left = this.evaluateExpression(expr.left);
				right = this.evaluateExpression(expr.right);
				if(!left || !right) return;
				if(!left.isNumber() || !right.isNumber()) return;
				res = new BasicEvaluatedExpression();
				res.setNumber(left.number - right.number);
				res.setRange(expr.range);
				return res;
			} else if(expr.operator === "*") {
				left = this.evaluateExpression(expr.left);
				right = this.evaluateExpression(expr.right);
				if(!left || !right) return;
				if(!left.isNumber() || !right.isNumber()) return;
				res = new BasicEvaluatedExpression();
				res.setNumber(left.number * right.number);
				res.setRange(expr.range);
				return res;
			} else if(expr.operator === "/") {
				left = this.evaluateExpression(expr.left);
				right = this.evaluateExpression(expr.right);
				if(!left || !right) return;
				if(!left.isNumber() || !right.isNumber()) return;
				res = new BasicEvaluatedExpression();
				res.setNumber(left.number / right.number);
				res.setRange(expr.range);
				return res;
			} else if(expr.operator === "==" || expr.operator === "===") {
				left = this.evaluateExpression(expr.left);
				right = this.evaluateExpression(expr.right);
				if(!left || !right) return;
				res = new BasicEvaluatedExpression();
				res.setRange(expr.range);
				if(left.isString() && right.isString()) {
					return res.setBoolean(left.string === right.string);
				} else if(left.isNumber() && right.isNumber()) {
					return res.setBoolean(left.number === right.number);
				} else if(left.isBoolean() && right.isBoolean()) {
					return res.setBoolean(left.bool === right.bool);
				}
			} else if(expr.operator === "!=" || expr.operator === "!==") {
				left = this.evaluateExpression(expr.left);
				right = this.evaluateExpression(expr.right);
				if(!left || !right) return;
				res = new BasicEvaluatedExpression();
				res.setRange(expr.range);
				if(left.isString() && right.isString()) {
					return res.setBoolean(left.string !== right.string);
				} else if(left.isNumber() && right.isNumber()) {
					return res.setBoolean(left.number !== right.number);
				} else if(left.isBoolean() && right.isBoolean()) {
					return res.setBoolean(left.bool !== right.bool);
				}
			}
		});
		this.plugin("evaluate UnaryExpression", function(expr) {
			if(expr.operator === "typeof") {
				let res;
				let name;
				if(expr.argument.type === "Identifier") {
					name = this.scope.renames["$" + expr.argument.name] || expr.argument.name;
					if(this.scope.definitions.indexOf(name) === -1) {
						res = this.applyPluginsBailResult1("evaluate typeof " + name, expr);
						if(res !== undefined) return res;
					}
				}
				if(expr.argument.type === "MemberExpression") {
					let expression = expr.argument;
					let exprName = [];
					while(expression.type === "MemberExpression" && !expression.computed) {
						exprName.unshift(this.scope.renames["$" + expression.property.name] || expression.property.name);
						expression = expression.object;
					}
					if(expression.type === "Identifier") {
						exprName.unshift(this.scope.renames["$" + expression.name] || expression.name);
						if(this.scope.definitions.indexOf(name) === -1) {
							exprName = exprName.join(".");
							res = this.applyPluginsBailResult1("evaluate typeof " + exprName, expr);
							if(res !== undefined) return res;
						}
					}
				}
				if(expr.argument.type === "FunctionExpression") {
					return new BasicEvaluatedExpression().setString("function").setRange(expr.range);
				}
				const arg = this.evaluateExpression(expr.argument);
				if(arg.isString() || arg.isWrapped()) return new BasicEvaluatedExpression().setString("string").setRange(expr.range);
				else if(arg.isNumber()) return new BasicEvaluatedExpression().setString("number").setRange(expr.range);
				else if(arg.isBoolean()) return new BasicEvaluatedExpression().setString("boolean").setRange(expr.range);
				else if(arg.isArray() || arg.isConstArray() || arg.isRegExp()) return new BasicEvaluatedExpression().setString("object").setRange(expr.range);
			} else if(expr.operator === "!") {
				const argument = this.evaluateExpression(expr.argument);
				if(!argument) return;
				if(argument.isBoolean()) {
					return new BasicEvaluatedExpression().setBoolean(!argument.bool).setRange(expr.range);
				} else if(argument.isString()) {
					return new BasicEvaluatedExpression().setBoolean(!argument.string).setRange(expr.range);
				} else if(argument.isNumber()) {
					return new BasicEvaluatedExpression().setBoolean(!argument.number).setRange(expr.range);
				}
			}
		});
		this.plugin("evaluate typeof undefined", function(expr) {
			return new BasicEvaluatedExpression().setString("undefined").setRange(expr.range);
		});
		this.plugin("evaluate Identifier", function(expr) {
			const name = this.scope.renames["$" + expr.name] || expr.name;
			if(this.scope.definitions.indexOf(expr.name) === -1) {
				const result = this.applyPluginsBailResult1("evaluate Identifier " + name, expr);
				if(result) return result;
				return new BasicEvaluatedExpression().setIdentifier(name).setRange(expr.range);
			} else {
				return this.applyPluginsBailResult1("evaluate defined Identifier " + name, expr);
			}
		});
		this.plugin("evaluate MemberExpression", function(expression) {
			let expr = expression;
			let exprName = [];
			while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
				exprName.unshift(expr.property.name || expr.property.value);
				expr = expr.object;
			}
			if(expr.type === "Identifier") {
				const name = this.scope.renames["$" + expr.name] || expr.name;
				if(this.scope.definitions.indexOf(name) === -1) {
					exprName.unshift(name);
					exprName = exprName.join(".");
					if(this.scope.definitions.indexOf(expr.name) === -1) {
						const result = this.applyPluginsBailResult1("evaluate Identifier " + exprName, expression);
						if(result) return result;
						return new BasicEvaluatedExpression().setIdentifier(exprName).setRange(expression.range);
					} else {
						return this.applyPluginsBailResult1("evaluate defined Identifier " + exprName, expression);
					}
				}
			}
		});
		this.plugin("evaluate CallExpression", function(expr) {
			if(expr.callee.type !== "MemberExpression") return;
			if(expr.callee.property.type !== (expr.callee.computed ? "Literal" : "Identifier")) return;
			const param = this.evaluateExpression(expr.callee.object);
			if(!param) return;
			const property = expr.callee.property.name || expr.callee.property.value;
			return this.applyPluginsBailResult("evaluate CallExpression ." + property, expr, param);
		});
		this.plugin("evaluate CallExpression .replace", function(expr, param) {
			if(!param.isString()) return;
			if(expr.arguments.length !== 2) return;
			let arg1 = this.evaluateExpression(expr.arguments[0]);
			let arg2 = this.evaluateExpression(expr.arguments[1]);
			if(!arg1.isString() && !arg1.isRegExp()) return;
			arg1 = arg1.regExp || arg1.string;
			if(!arg2.isString()) return;
			arg2 = arg2.string;
			return new BasicEvaluatedExpression().setString(param.string.replace(arg1, arg2)).setRange(expr.range);
		});
		["substr", "substring"].forEach(fn => {
			this.plugin("evaluate CallExpression ." + fn, function(expr, param) {
				if(!param.isString()) return;
				let arg1;
				let result, str = param.string;
				switch(expr.arguments.length) {
					case 1:
						arg1 = this.evaluateExpression(expr.arguments[0]);
						if(!arg1.isNumber()) return;
						result = str[fn](arg1.number);
						break;
					case 2:
						{
							arg1 = this.evaluateExpression(expr.arguments[0]);
							const arg2 = this.evaluateExpression(expr.arguments[1]);
							if(!arg1.isNumber()) return;
							if(!arg2.isNumber()) return;
							result = str[fn](arg1.number, arg2.number);
							break;
						}
					default:
						return;
				}
				return new BasicEvaluatedExpression().setString(result).setRange(expr.range);
			});
 
			/**
			 * @param {string} kind "cooked" | "raw"
			 * @param {any[]} quasis quasis
			 * @param {any[]} expressions expressions
			 * @return {BasicEvaluatedExpression[]} Simplified template
			 */
			function getSimplifiedTemplateResult(kind, quasis, expressions) {
				const parts = [];
 
				for(let i = 0; i < quasis.length; i++) {
					parts.push(new BasicEvaluatedExpression().setString(quasis[i].value[kind]).setRange(quasis[i].range));
 
					if(i > 0) {
						const prevExpr = parts[parts.length - 2],
							lastExpr = parts[parts.length - 1];
						const expr = this.evaluateExpression(expressions[i - 1]);
						if(!(expr.isString() || expr.isNumber())) continue;
 
						prevExpr.setString(prevExpr.string + (expr.isString() ? expr.string : expr.number) + lastExpr.string);
						prevExpr.setRange([prevExpr.range[0], lastExpr.range[1]]);
						parts.pop();
					}
				}
				return parts;
			}
 
			this.plugin("evaluate TemplateLiteral", function(node) {
				const parts = getSimplifiedTemplateResult.call(this, "cooked", node.quasis, node.expressions);
				if(parts.length === 1) {
					return parts[0].setRange(node.range);
				}
				return new BasicEvaluatedExpression().setTemplateString(parts).setRange(node.range);
			});
			this.plugin("evaluate TaggedTemplateExpression", function(node) {
				if(this.evaluateExpression(node.tag).identifier !== "String.raw") return;
				const parts = getSimplifiedTemplateResult.call(this, "raw", node.quasi.quasis, node.quasi.expressions);
				return new BasicEvaluatedExpression().setTemplateString(parts).setRange(node.range);
			});
		});
		this.plugin("evaluate CallExpression .split", function(expr, param) {
			if(!param.isString()) return;
			if(expr.arguments.length !== 1) return;
			let result;
			const arg = this.evaluateExpression(expr.arguments[0]);
			if(arg.isString()) {
				result = param.string.split(arg.string);
			} else if(arg.isRegExp()) {
				result = param.string.split(arg.regExp);
			} else return;
			return new BasicEvaluatedExpression().setArray(result).setRange(expr.range);
		});
		this.plugin("evaluate ConditionalExpression", function(expr) {
			const condition = this.evaluateExpression(expr.test);
			const conditionValue = condition.asBool();
			let res;
			if(conditionValue === undefined) {
				const consequent = this.evaluateExpression(expr.consequent);
				const alternate = this.evaluateExpression(expr.alternate);
				if(!consequent || !alternate) return;
				res = new BasicEvaluatedExpression();
				if(consequent.isConditional())
					res.setOptions(consequent.options);
				else
					res.setOptions([consequent]);
				if(alternate.isConditional())
					res.addOptions(alternate.options);
				else
					res.addOptions([alternate]);
			} else {
				res = this.evaluateExpression(conditionValue ? expr.consequent : expr.alternate);
			}
			res.setRange(expr.range);
			return res;
		});
		this.plugin("evaluate ArrayExpression", function(expr) {
			const items = expr.elements.map(function(element) {
				return element !== null && this.evaluateExpression(element);
			}, this);
			if(!items.every(Boolean)) return;
			return new BasicEvaluatedExpression().setItems(items).setRange(expr.range);
		});
	}
 
	getRenameIdentifier(expr) {
		const result = this.evaluateExpression(expr);
		if(!result) return;
		if(result.isIdentifier()) return result.identifier;
		return;
	}
 
	walkClass(classy) {
		if(classy.superClass)
			this.walkExpression(classy.superClass);
		if(classy.body && classy.body.type === "ClassBody") {
			classy.body.body.forEach(methodDefinition => {
				if(methodDefinition.type === "MethodDefinition")
					this.walkMethodDefinition(methodDefinition);
			});
		}
	}
 
	walkMethodDefinition(methodDefinition) {
		if(methodDefinition.computed && methodDefinition.key)
			this.walkExpression(methodDefinition.key);
		if(methodDefinition.value)
			this.walkExpression(methodDefinition.value);
	}
 
	// Prewalking iterates the scope for variable declarations
	prewalkStatements(statements) {
		for(let index = 0, len = statements.length; index < len; index++) {
			const statement = statements[index];
			this.prewalkStatement(statement);
		}
	}
 
	// Walking iterates the statements and expressions and processes them
	walkStatements(statements) {
		for(let index = 0, len = statements.length; index < len; index++) {
			const statement = statements[index];
			this.walkStatement(statement);
		}
	}
 
	prewalkStatement(statement) {
		const handler = this["prewalk" + statement.type];
		if(handler)
			handler.call(this, statement);
	}
 
	walkStatement(statement) {
		if(this.applyPluginsBailResult1("statement", statement) !== undefined) return;
		const handler = this["walk" + statement.type];
		if(handler)
			handler.call(this, statement);
	}
 
	// Real Statements
	prewalkBlockStatement(statement) {
		this.prewalkStatements(statement.body);
	}
 
	walkBlockStatement(statement) {
		this.walkStatements(statement.body);
	}
 
	walkExpressionStatement(statement) {
		this.walkExpression(statement.expression);
	}
 
	prewalkIfStatement(statement) {
		this.prewalkStatement(statement.consequent);
		if(statement.alternate)
			this.prewalkStatement(statement.alternate);
	}
 
	walkIfStatement(statement) {
		const result = this.applyPluginsBailResult1("statement if", statement);
		if(result === undefined) {
			this.walkExpression(statement.test);
			this.walkStatement(statement.consequent);
			if(statement.alternate)
				this.walkStatement(statement.alternate);
		} else {
			if(result)
				this.walkStatement(statement.consequent);
			else if(statement.alternate)
				this.walkStatement(statement.alternate);
		}
	}
 
	prewalkLabeledStatement(statement) {
		this.prewalkStatement(statement.body);
	}
 
	walkLabeledStatement(statement) {
		const result = this.applyPluginsBailResult1("label " + statement.label.name, statement);
		if(result !== true)
			this.walkStatement(statement.body);
	}
 
	prewalkWithStatement(statement) {
		this.prewalkStatement(statement.body);
	}
 
	walkWithStatement(statement) {
		this.walkExpression(statement.object);
		this.walkStatement(statement.body);
	}
 
	prewalkSwitchStatement(statement) {
		this.prewalkSwitchCases(statement.cases);
	}
 
	walkSwitchStatement(statement) {
		this.walkExpression(statement.discriminant);
		this.walkSwitchCases(statement.cases);
	}
 
	walkTerminatingStatement(statement) {
		if(statement.argument)
			this.walkExpression(statement.argument);
	}
 
	walkReturnStatement(statement) {
		this.walkTerminatingStatement(statement);
	}
 
	walkThrowStatement(statement) {
		this.walkTerminatingStatement(statement);
	}
 
	prewalkTryStatement(statement) {
		this.prewalkStatement(statement.block);
	}
 
	walkTryStatement(statement) {
		if(this.scope.inTry) {
			this.walkStatement(statement.block);
		} else {
			this.scope.inTry = true;
			this.walkStatement(statement.block);
			this.scope.inTry = false;
		}
		if(statement.handler)
			this.walkCatchClause(statement.handler);
		if(statement.finalizer)
			this.walkStatement(statement.finalizer);
	}
 
	prewalkWhileStatement(statement) {
		this.prewalkStatement(statement.body);
	}
 
	walkWhileStatement(statement) {
		this.walkExpression(statement.test);
		this.walkStatement(statement.body);
	}
 
	prewalkDoWhileStatement(statement) {
		this.prewalkStatement(statement.body);
	}
 
	walkDoWhileStatement(statement) {
		this.walkStatement(statement.body);
		this.walkExpression(statement.test);
	}
 
	prewalkForStatement(statement) {
		if(statement.init) {
			if(statement.init.type === "VariableDeclaration")
				this.prewalkStatement(statement.init);
		}
		this.prewalkStatement(statement.body);
	}
 
	walkForStatement(statement) {
		if(statement.init) {
			if(statement.init.type === "VariableDeclaration")
				this.walkStatement(statement.init);
			else
				this.walkExpression(statement.init);
		}
		if(statement.test)
			this.walkExpression(statement.test);
		if(statement.update)
			this.walkExpression(statement.update);
		this.walkStatement(statement.body);
	}
 
	prewalkForInStatement(statement) {
		if(statement.left.type === "VariableDeclaration")
			this.prewalkStatement(statement.left);
		this.prewalkStatement(statement.body);
	}
 
	walkForInStatement(statement) {
		if(statement.left.type === "VariableDeclaration")
			this.walkStatement(statement.left);
		else
			this.walkExpression(statement.left);
		this.walkExpression(statement.right);
		this.walkStatement(statement.body);
	}
 
	prewalkForOfStatement(statement) {
		if(statement.left.type === "VariableDeclaration")
			this.prewalkStatement(statement.left);
		this.prewalkStatement(statement.body);
	}
 
	walkForOfStatement(statement) {
		if(statement.left.type === "VariableDeclaration")
			this.walkStatement(statement.left);
		else
			this.walkExpression(statement.left);
		this.walkExpression(statement.right);
		this.walkStatement(statement.body);
	}
 
	// Declarations
	prewalkFunctionDeclaration(statement) {
		if(statement.id) {
			this.scope.renames["$" + statement.id.name] = undefined;
			this.scope.definitions.push(statement.id.name);
		}
	}
 
	walkFunctionDeclaration(statement) {
		this.inScope(statement.params, function() {
			if(statement.body.type === "BlockStatement") {
				this.prewalkStatement(statement.body);
				this.walkStatement(statement.body);
			} else {
				this.walkExpression(statement.body);
			}
		}.bind(this));
	}
 
	prewalkImportDeclaration(statement) {
		const source = statement.source.value;
		this.applyPluginsBailResult("import", statement, source);
		statement.specifiers.forEach(function(specifier) {
			const name = specifier.local.name;
			this.scope.renames["$" + name] = undefined;
			this.scope.definitions.push(name);
			switch(specifier.type) {
				case "ImportDefaultSpecifier":
					this.applyPluginsBailResult("import specifier", statement, source, "default", name);
					break;
				case "ImportSpecifier":
					this.applyPluginsBailResult("import specifier", statement, source, specifier.imported.name, name);
					break;
				case "ImportNamespaceSpecifier":
					this.applyPluginsBailResult("import specifier", statement, source, null, name);
					break;
			}
		}, this);
	}
 
	prewalkExportNamedDeclaration(statement) {
		let source;
		if(statement.source) {
			source = statement.source.value;
			this.applyPluginsBailResult("export import", statement, source);
		} else {
			this.applyPluginsBailResult1("export", statement);
		}
		if(statement.declaration) {
			if(/Expression$/.test(statement.declaration.type)) {
				throw new Error("Doesn't occur?");
			} else {
				if(!this.applyPluginsBailResult("export declaration", statement, statement.declaration)) {
					const pos = this.scope.definitions.length;
					this.prewalkStatement(statement.declaration);
					const newDefs = this.scope.definitions.slice(pos);
					for(let index = newDefs.length - 1; index >= 0; index--) {
						const def = newDefs[index];
						this.applyPluginsBailResult("export specifier", statement, def, def, index);
					}
				}
			}
		}
		if(statement.specifiers) {
			for(let specifierIndex = 0; specifierIndex < statement.specifiers.length; specifierIndex++) {
				const specifier = statement.specifiers[specifierIndex];
				switch(specifier.type) {
					case "ExportSpecifier":
						{
							const name = specifier.exported.name;
							if(source)
								this.applyPluginsBailResult("export import specifier", statement, source, specifier.local.name, name, specifierIndex);
							else
								this.applyPluginsBailResult("export specifier", statement, specifier.local.name, name, specifierIndex);
							break;
						}
				}
			}
		}
	}
 
	walkExportNamedDeclaration(statement) {
		if(statement.declaration) {
			this.walkStatement(statement.declaration);
		}
	}
 
	prewalkExportDefaultDeclaration(statement) {
		if(/Declaration$/.test(statement.declaration.type)) {
			const pos = this.scope.definitions.length;
			this.prewalkStatement(statement.declaration);
			const newDefs = this.scope.definitions.slice(pos);
			for(let index = 0, len = newDefs.length; index < len; index++) {
				const def = newDefs[index];
				this.applyPluginsBailResult("export specifier", statement, def, "default");
			}
		}
	}
 
	walkExportDefaultDeclaration(statement) {
		this.applyPluginsBailResult1("export", statement);
		if(/Declaration$/.test(statement.declaration.type)) {
			if(!this.applyPluginsBailResult("export declaration", statement, statement.declaration)) {
				this.walkStatement(statement.declaration);
			}
		} else {
			this.walkExpression(statement.declaration);
			if(!this.applyPluginsBailResult("export expression", statement, statement.declaration)) {
				this.applyPluginsBailResult("export specifier", statement, statement.declaration, "default");
			}
		}
	}
 
	prewalkExportAllDeclaration(statement) {
		const source = statement.source.value;
		this.applyPluginsBailResult("export import", statement, source);
		this.applyPluginsBailResult("export import specifier", statement, source, null, null, 0);
	}
 
	prewalkVariableDeclaration(statement) {
		if(statement.declarations)
			this.prewalkVariableDeclarators(statement.declarations);
	}
 
	walkVariableDeclaration(statement) {
		if(statement.declarations)
			this.walkVariableDeclarators(statement.declarations);
	}
 
	prewalkClassDeclaration(statement) {
		if(statement.id) {
			this.scope.renames["$" + statement.id.name] = undefined;
			this.scope.definitions.push(statement.id.name);
		}
	}
 
	walkClassDeclaration(statement) {
		this.walkClass(statement);
	}
 
	prewalkSwitchCases(switchCases) {
		for(let index = 0, len = switchCases.length; index < len; index++) {
			const switchCase = switchCases[index];
			this.prewalkStatements(switchCase.consequent);
		}
	}
 
	walkSwitchCases(switchCases) {
		for(let index = 0, len = switchCases.length; index < len; index++) {
			const switchCase = switchCases[index];
 
			if(switchCase.test) {
				this.walkExpression(switchCase.test);
			}
			this.walkStatements(switchCase.consequent);
		}
	}
 
	walkCatchClause(catchClause) {
		this.inScope([catchClause.param], function() {
			this.prewalkStatement(catchClause.body);
			this.walkStatement(catchClause.body);
		}.bind(this));
	}
 
	prewalkVariableDeclarators(declarators) {
		declarators.forEach(declarator => {
			switch(declarator.type) {
				case "VariableDeclarator":
					{
						const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init);
						if(renameIdentifier && declarator.id.type === "Identifier" && this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
							// renaming with "var a = b;"
							if(!this.applyPluginsBailResult1("rename " + renameIdentifier, declarator.init)) {
								this.scope.renames["$" + declarator.id.name] = this.scope.renames["$" + renameIdentifier] || renameIdentifier;
								const idx = this.scope.definitions.indexOf(declarator.id.name);
								if(idx >= 0) this.scope.definitions.splice(idx, 1);
							}
						} else {
							this.enterPattern(declarator.id, (name, decl) => {
								if(!this.applyPluginsBailResult1("var-" + declarator.kind + " " + name, decl)) {
									if(!this.applyPluginsBailResult1("var " + name, decl)) {
										this.scope.renames["$" + name] = undefined;
										this.scope.definitions.push(name);
									}
								}
							});
						}
						break;
					}
			}
		});
	}
 
	walkVariableDeclarators(declarators) {
		declarators.forEach(declarator => {
			switch(declarator.type) {
				case "VariableDeclarator":
					{
						const renameIdentifier = declarator.init && this.getRenameIdentifier(declarator.init);
						if(!renameIdentifier || declarator.id.type !== "Identifier" || !this.applyPluginsBailResult1("can-rename " + renameIdentifier, declarator.init)) {
							this.walkPattern(declarator.id);
							if(declarator.init)
								this.walkExpression(declarator.init);
						}
						break;
					}
			}
		});
	}
 
	walkPattern(pattern) {
		if(pattern.type === "Identifier")
			return;
		if(this["walk" + pattern.type])
			this["walk" + pattern.type](pattern);
	}
 
	walkObjectPattern(pattern) {
		for(let i = 0, len = pattern.properties.length; i < len; i++) {
			const prop = pattern.properties[i];
			if(prop) {
				if(prop.computed)
					this.walkExpression(prop.key);
				if(prop.value)
					this.walkPattern(prop.value);
			}
		}
	}
 
	walkArrayPattern(pattern) {
		for(let i = 0, len = pattern.elements.length; i < len; i++) {
			const element = pattern.elements[i];
			if(element)
				this.walkPattern(element);
		}
	}
 
	walkRestElement(pattern) {
		this.walkPattern(pattern.argument);
	}
 
	walkExpressions(expressions) {
		for(let expressionsIndex = 0, len = expressions.length; expressionsIndex < len; expressionsIndex++) {
			const expression = expressions[expressionsIndex];
			if(expression)
				this.walkExpression(expression);
		}
	}
 
	walkExpression(expression) {
		if(this["walk" + expression.type])
			return this["walk" + expression.type](expression);
	}
 
	walkAwaitExpression(expression) {
		const argument = expression.argument;
		if(this["walk" + argument.type])
			return this["walk" + argument.type](argument);
	}
 
	walkArrayExpression(expression) {
		if(expression.elements)
			this.walkExpressions(expression.elements);
	}
 
	walkSpreadElement(expression) {
		if(expression.argument)
			this.walkExpression(expression.argument);
	}
 
	walkObjectExpression(expression) {
		for(let propIndex = 0, len = expression.properties.length; propIndex < len; propIndex++) {
			const prop = expression.properties[propIndex];
			if(prop.computed)
				this.walkExpression(prop.key);
			if(prop.shorthand)
				this.scope.inShorthand = true;
			this.walkExpression(prop.value);
			if(prop.shorthand)
				this.scope.inShorthand = false;
		}
	}
 
	walkFunctionExpression(expression) {
		this.inScope(expression.params, function() {
			if(expression.body.type === "BlockStatement") {
				this.prewalkStatement(expression.body);
				this.walkStatement(expression.body);
			} else {
				this.walkExpression(expression.body);
			}
		}.bind(this));
	}
 
	walkArrowFunctionExpression(expression) {
		this.inScope(expression.params, function() {
			if(expression.body.type === "BlockStatement") {
				this.prewalkStatement(expression.body);
				this.walkStatement(expression.body);
			} else {
				this.walkExpression(expression.body);
			}
		}.bind(this));
	}
 
	walkSequenceExpression(expression) {
		if(expression.expressions)
			this.walkExpressions(expression.expressions);
	}
 
	walkUpdateExpression(expression) {
		this.walkExpression(expression.argument);
	}
 
	walkUnaryExpression(expression) {
		if(expression.operator === "typeof") {
			let expr = expression.argument;
			let exprName = [];
			while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
				exprName.unshift(expr.property.name || expr.property.value);
				expr = expr.object;
			}
			if(expr.type === "Identifier" && this.scope.definitions.indexOf(expr.name) === -1) {
				exprName.unshift(this.scope.renames["$" + expr.name] || expr.name);
				exprName = exprName.join(".");
				const result = this.applyPluginsBailResult1("typeof " + exprName, expression);
				if(result === true)
					return;
			}
		}
		this.walkExpression(expression.argument);
	}
 
	walkLeftRightExpression(expression) {
		this.walkExpression(expression.left);
		this.walkExpression(expression.right);
	}
 
	walkBinaryExpression(expression) {
		this.walkLeftRightExpression(expression);
	}
 
	walkLogicalExpression(expression) {
		this.walkLeftRightExpression(expression);
	}
 
	walkAssignmentExpression(expression) {
		const renameIdentifier = this.getRenameIdentifier(expression.right);
		if(expression.left.type === "Identifier" && renameIdentifier && this.applyPluginsBailResult1("can-rename " + renameIdentifier, expression.right)) {
			// renaming "a = b;"
			if(!this.applyPluginsBailResult1("rename " + renameIdentifier, expression.right)) {
				this.scope.renames["$" + expression.left.name] = renameIdentifier;
				const idx = this.scope.definitions.indexOf(expression.left.name);
				if(idx >= 0) this.scope.definitions.splice(idx, 1);
			}
		} else if(expression.left.type === "Identifier") {
			if(!this.applyPluginsBailResult1("assigned " + expression.left.name, expression)) {
				this.walkExpression(expression.right);
			}
			this.scope.renames["$" + expression.left.name] = undefined;
			if(!this.applyPluginsBailResult1("assign " + expression.left.name, expression)) {
				this.walkExpression(expression.left);
			}
		} else {
			this.walkExpression(expression.right);
			this.scope.renames["$" + expression.left.name] = undefined;
			this.walkExpression(expression.left);
		}
	}
 
	walkConditionalExpression(expression) {
		const result = this.applyPluginsBailResult1("expression ?:", expression);
		if(result === undefined) {
			this.walkExpression(expression.test);
			this.walkExpression(expression.consequent);
			if(expression.alternate)
				this.walkExpression(expression.alternate);
		} else {
			if(result)
				this.walkExpression(expression.consequent);
			else if(expression.alternate)
				this.walkExpression(expression.alternate);
		}
	}
 
	walkNewExpression(expression) {
		this.walkExpression(expression.callee);
		if(expression.arguments)
			this.walkExpressions(expression.arguments);
	}
 
	walkYieldExpression(expression) {
		if(expression.argument)
			this.walkExpression(expression.argument);
	}
 
	walkTemplateLiteral(expression) {
		if(expression.expressions)
			this.walkExpressions(expression.expressions);
	}
 
	walkTaggedTemplateExpression(expression) {
		if(expression.tag)
			this.walkExpression(expression.tag);
		if(expression.quasi && expression.quasi.expressions)
			this.walkExpressions(expression.quasi.expressions);
	}
 
	walkClassExpression(expression) {
		this.walkClass(expression);
	}
 
	walkCallExpression(expression) {
		let result;
 
		function walkIIFE(functionExpression, options) {
			const params = functionExpression.params;
			const args = options.map(function(arg) {
				const renameIdentifier = this.getRenameIdentifier(arg);
				if(renameIdentifier && this.applyPluginsBailResult1("can-rename " + renameIdentifier, arg)) {
					if(!this.applyPluginsBailResult1("rename " + renameIdentifier, arg))
						return renameIdentifier;
				}
				this.walkExpression(arg);
			}, this);
			this.inScope(params.filter(function(identifier, idx) {
				return !args[idx];
			}), function() {
				for(let i = 0; i < args.length; i++) {
					const param = args[i];
					if(!param) continue;
					if(!params[i] || params[i].type !== "Identifier") continue;
					this.scope.renames["$" + params[i].name] = param;
				}
				if(functionExpression.body.type === "BlockStatement") {
					this.prewalkStatement(functionExpression.body);
					this.walkStatement(functionExpression.body);
				} else
					this.walkExpression(functionExpression.body);
			}.bind(this));
		}
		if(expression.callee.type === "MemberExpression" &&
			expression.callee.object.type === "FunctionExpression" &&
			!expression.callee.computed &&
			(["call", "bind"]).indexOf(expression.callee.property.name) >= 0 &&
			expression.arguments &&
			expression.arguments.length > 1
		) {
			// (function(...) { }.call/bind(?, ...))
			walkIIFE.call(this, expression.callee.object, expression.arguments.slice(1));
			this.walkExpression(expression.arguments[0]);
		} else if(expression.callee.type === "FunctionExpression" && expression.arguments) {
			// (function(...) { }(...))
			walkIIFE.call(this, expression.callee, expression.arguments);
		} else if(expression.callee.type === "Import") {
			result = this.applyPluginsBailResult1("import-call", expression);
			if(result === true)
				return;
 
			if(expression.arguments)
				this.walkExpressions(expression.arguments);
		} else {
 
			const callee = this.evaluateExpression(expression.callee);
			if(callee.isIdentifier()) {
				result = this.applyPluginsBailResult1("call " + callee.identifier, expression);
				if(result === true)
					return;
			}
 
			if(expression.callee)
				this.walkExpression(expression.callee);
			if(expression.arguments)
				this.walkExpressions(expression.arguments);
		}
	}
 
	walkMemberExpression(expression) {
		let expr = expression;
		let exprName = [];
		while(expr.type === "MemberExpression" && expr.property.type === (expr.computed ? "Literal" : "Identifier")) {
			exprName.unshift(expr.property.name || expr.property.value);
			expr = expr.object;
		}
		if(expr.type === "Identifier" && this.scope.definitions.indexOf(expr.name) === -1) {
			exprName.unshift(this.scope.renames["$" + expr.name] || expr.name);
			let result = this.applyPluginsBailResult1("expression " + exprName.join("."), expression);
			if(result === true)
				return;
			exprName[exprName.length - 1] = "*";
			result = this.applyPluginsBailResult1("expression " + exprName.join("."), expression);
			if(result === true)
				return;
		}
		this.walkExpression(expression.object);
		if(expression.computed === true)
			this.walkExpression(expression.property);
	}
 
	walkIdentifier(expression) {
		if(this.scope.definitions.indexOf(expression.name) === -1) {
			const result = this.applyPluginsBailResult1("expression " + (this.scope.renames["$" + expression.name] || expression.name), expression);
			if(result === true)
				return;
		}
	}
 
	inScope(params, fn) {
		const oldScope = this.scope;
		this.scope = {
			inTry: false,
			inShorthand: false,
			definitions: oldScope.definitions.slice(),
			renames: Object.create(oldScope.renames)
		};
 
		for(let paramIndex = 0, len = params.length; paramIndex < len; paramIndex++) {
			const param = params[paramIndex];
 
			if(typeof param !== "string") {
				this.enterPattern(param, param => {
					this.scope.renames["$" + param] = undefined;
					this.scope.definitions.push(param);
				});
			} else {
				this.scope.renames["$" + param] = undefined;
				this.scope.definitions.push(param);
			}
		}
 
		fn();
		this.scope = oldScope;
	}
 
	enterPattern(pattern, onIdent) {
		if(pattern && this["enter" + pattern.type])
			this["enter" + pattern.type](pattern, onIdent);
	}
 
	enterIdentifier(pattern, onIdent) {
		onIdent(pattern.name, pattern);
	}
 
	enterObjectPattern(pattern, onIdent) {
		for(let propIndex = 0, len = pattern.properties.length; propIndex < len; propIndex++) {
			const prop = pattern.properties[propIndex];
			this.enterPattern(prop.value, onIdent);
		}
	}
 
	enterArrayPattern(pattern, onIdent) {
		for(let elementIndex = 0, len = pattern.elements.length; elementIndex < len; elementIndex++) {
			const element = pattern.elements[elementIndex];
			this.enterPattern(element, onIdent);
		}
	}
 
	enterRestElement(pattern, onIdent) {
		this.enterPattern(pattern.argument, onIdent);
	}
 
	enterAssignmentPattern(pattern, onIdent) {
		this.enterPattern(pattern.left, onIdent);
		this.walkExpression(pattern.right);
	}
 
	evaluateExpression(expression) {
		try {
			const result = this.applyPluginsBailResult1("evaluate " + expression.type, expression);
			if(result !== undefined)
				return result;
		} catch(e) {
			console.warn(e);
			// ignore error
		}
		return new BasicEvaluatedExpression().setRange(expression.range);
	}
 
	parseString(expression) {
		switch(expression.type) {
			case "BinaryExpression":
				if(expression.operator === "+")
					return this.parseString(expression.left) + this.parseString(expression.right);
				break;
			case "Literal":
				return expression.value + "";
		}
		throw new Error(expression.type + " is not supported as parameter for require");
	}
 
	parseCalculatedString(expression) {
		switch(expression.type) {
			case "BinaryExpression":
				if(expression.operator === "+") {
					const left = this.parseCalculatedString(expression.left);
					const right = this.parseCalculatedString(expression.right);
					if(left.code) {
						return {
							range: left.range,
							value: left.value,
							code: true
						};
					} else if(right.code) {
						return {
							range: [left.range[0], right.range ? right.range[1] : left.range[1]],
							value: left.value + right.value,
							code: true
						};
					} else {
						return {
							range: [left.range[0], right.range[1]],
							value: left.value + right.value
						};
					}
				}
				break;
			case "ConditionalExpression":
				{
					const consequent = this.parseCalculatedString(expression.consequent);
					const alternate = this.parseCalculatedString(expression.alternate);
					const items = [];
					if(consequent.conditional)
						Array.prototype.push.apply(items, consequent.conditional);
					else if(!consequent.code)
						items.push(consequent);
					else break;
					if(alternate.conditional)
						Array.prototype.push.apply(items, alternate.conditional);
					else if(!alternate.code)
						items.push(alternate);
					else break;
					return {
						value: "",
						code: true,
						conditional: items
					};
				}
			case "Literal":
				return {
					range: expression.range,
					value: expression.value + ""
				};
		}
		return {
			value: "",
			code: true
		};
	}
 
	parseStringArray(expression) {
		if(expression.type !== "ArrayExpression") {
			return [this.parseString(expression)];
		}
 
		const arr = [];
		if(expression.elements)
			expression.elements.forEach(function(expr) {
				arr.push(this.parseString(expr));
			}, this);
		return arr;
	}
 
	parseCalculatedStringArray(expression) {
		if(expression.type !== "ArrayExpression") {
			return [this.parseCalculatedString(expression)];
		}
 
		const arr = [];
		if(expression.elements)
			expression.elements.forEach(function(expr) {
				arr.push(this.parseCalculatedString(expr));
			}, this);
		return arr;
	}
 
	parse(source, initialState) {
		let ast;
		const comments = [];
		for(let i = 0, len = POSSIBLE_AST_OPTIONS.length; i < len; i++) {
			if(!ast) {
				try {
					comments.length = 0;
					POSSIBLE_AST_OPTIONS[i].onComment = comments;
					ast = acorn.parse(source, POSSIBLE_AST_OPTIONS[i]);
				} catch(e) {
					// ignore the error
				}
			}
		}
		if(!ast) {
			// for the error
			ast = acorn.parse(source, {
				ranges: true,
				locations: true,
				ecmaVersion: 2017,
				sourceType: "module",
				plugins: {
					dynamicImport: true
				},
				onComment: comments
			});
		}
		if(!ast || typeof ast !== "object")
			throw new Error("Source couldn't be parsed");
		const oldScope = this.scope;
		const oldState = this.state;
		const oldComments = this.comments;
		this.scope = {
			inTry: false,
			definitions: [],
			renames: {}
		};
		const state = this.state = initialState || {};
		this.comments = comments;
		if(this.applyPluginsBailResult("program", ast, comments) === undefined) {
			this.prewalkStatements(ast.body);
			this.walkStatements(ast.body);
		}
		this.scope = oldScope;
		this.state = oldState;
		this.comments = oldComments;
		return state;
	}
 
	evaluate(source) {
		const ast = acorn.parse("(" + source + ")", {
			ranges: true,
			locations: true,
			ecmaVersion: 2017,
			sourceType: "module",
			plugins: {
				dynamicImport: true
			}
		});
		if(!ast || typeof ast !== "object" || ast.type !== "Program")
			throw new Error("evaluate: Source couldn't be parsed");
		if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
			throw new Error("evaluate: Source is not a expression");
		return this.evaluateExpression(ast.body[0].expression);
	}
 
	getComments(range) {
		return this.comments.filter(comment => comment.range[0] >= range[0] && comment.range[1] <= range[1]);
	}
 
	getCommentOptions(range) {
		const comments = this.getComments(range);
		if(comments.length === 0) return null;
		const options = comments.map(comment => {
			try {
				return json5.parse(`{${comment.value}}`);
			} catch(e) {
				return {};
			}
		});
		return options.reduce((o, i) => Object.assign(o, i), {});
	}
 
}
 
module.exports = Parser;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ParserHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ParserHelpers.js

Statements: 29.55% (13 / 44)      Branches: 0% (0 / 6)      Functions: 0% (0 / 13)      Lines: 30.95% (13 / 42)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78          1   1 1 1   1   1                               1               1                 1           1           1                     1       1        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const path = require("path");
 
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
const ConstDependency = require("./dependencies/ConstDependency");
const UnsupportedFeatureWarning = require("./UnsupportedFeatureWarning");
 
const ParserHelpers = exports;
 
ParserHelpers.addParsedVariableToModule = function(parser, name, expression) {
	if(!parser.state.current.addVariable) return false;
	var deps = [];
	parser.parse(expression, {
		current: {
			addDependency: function(dep) {
				dep.userRequest = name;
				deps.push(dep);
			}
		},
		module: parser.state.module
	});
	parser.state.current.addVariable(name, expression, deps);
	return true;
};
 
ParserHelpers.requireFileAsExpression = function(context, pathToModule) {
	var moduleJsPath = path.relative(context, pathToModule);
	if(!/^[A-Z]:/i.test(moduleJsPath)) {
		moduleJsPath = "./" + moduleJsPath.replace(/\\/g, "/");
	}
	return "require(" + JSON.stringify(moduleJsPath) + ")";
};
 
ParserHelpers.toConstantDependency = function(value) {
	return function constDependency(expr) {
		var dep = new ConstDependency(value, expr.range);
		dep.loc = expr.loc;
		this.state.current.addDependency(dep);
		return true;
	};
};
 
ParserHelpers.evaluateToString = function(value) {
	return function stringExpression(expr) {
		return new BasicEvaluatedExpression().setString(value).setRange(expr.range);
	};
};
 
ParserHelpers.evaluateToBoolean = function(value) {
	return function booleanExpression(expr) {
		return new BasicEvaluatedExpression().setBoolean(value).setRange(expr.range);
	};
};
 
ParserHelpers.expressionIsUnsupported = function(message) {
	return function unsupportedExpression(expr) {
		var dep = new ConstDependency("(void 0)", expr.range);
		dep.loc = expr.loc;
		this.state.current.addDependency(dep);
		if(!this.state.module) return;
		this.state.module.warnings.push(new UnsupportedFeatureWarning(this.state.module, message));
		return true;
	};
};
 
ParserHelpers.skipTraversal = function skipTraversal() {
	return true;
};
 
ParserHelpers.approve = function approve() {
	return true;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/PrefetchPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/PrefetchPlugin.js

Statements: 18.18% (2 / 11)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 18.18% (2 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33          1                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const PrefetchDependency = require("./dependencies/PrefetchDependency");
 
class PrefetchPlugin {
 
	constructor(context, request) {
		if(!request) {
			this.request = context;
		} else {
			this.context = context;
			this.request = request;
		}
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(PrefetchDependency, normalModuleFactory);
		});
		compiler.plugin("make", (compilation, callback) => {
			compilation.prefetch(this.context || compiler.context, new PrefetchDependency(this.request), callback);
		});
	}
 
}
module.exports = PrefetchPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ProgressPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ProgressPlugin.js

Statements: 2.68% (3 / 112)      Branches: 0% (0 / 43)      Functions: 0% (0 / 10)      Lines: 2.8% (3 / 107)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192                                                                                                                                                                                                                                                                              1                                                                                 1                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class ProgressPlugin {
 
	constructor(options) {
		if(typeof options === "function") {
			options = {
				handler: options
			};
		}
		options = options || {};
		this.profile = options.profile;
		this.handler = options.handler;
	}
 
	apply(compiler) {
		const handler = this.handler || defaultHandler;
		const profile = this.profile;
		if(compiler.compilers) {
			const states = new Array(compiler.compilers.length);
			compiler.compilers.forEach(function(compiler, idx) {
				compiler.apply(new ProgressPlugin(function(p, msg) {
					states[idx] = Array.prototype.slice.apply(arguments);
					handler.apply(null, [
						states.map(state => state && state[0] || 0).reduce((a, b) => a + b) / states.length,
						`[${idx}] ${msg}`
					].concat(Array.prototype.slice.call(arguments, 2)));
				}));
			});
		} else {
			let lastModulesCount = 0;
			let moduleCount = 500;
			let doneModules = 0;
			const activeModules = [];
 
			const update = function update(module) {
				handler(
					0.1 + (doneModules / Math.max(lastModulesCount, moduleCount)) * 0.6,
					"building modules",
					`${doneModules}/${moduleCount} modules`,
					`${activeModules.length} active`,
					activeModules[activeModules.length - 1]
				);
			};
 
			const moduleDone = function moduleDone(module) {
				doneModules++;
				const ident = module.identifier();
				if(ident) {
					const idx = activeModules.indexOf(ident);
					if(idx >= 0) activeModules.splice(idx, 1);
				}
				update();
			};
			compiler.plugin("compilation", function(compilation) {
				if(compilation.compiler.isChild()) return;
				lastModulesCount = moduleCount;
				moduleCount = 0;
				doneModules = 0;
				handler(0, "compiling");
				compilation.plugin("build-module", function(module) {
					moduleCount++;
					const ident = module.identifier();
					if(ident) {
						activeModules.push(ident);
					}
					update();
				});
				compilation.plugin("failed-module", moduleDone);
				compilation.plugin("succeed-module", moduleDone);
				const syncHooks = {
					"seal": [0.71, "sealing"],
					"optimize": [0.72, "optimizing"],
					"optimize-modules-basic": [0.73, "basic module optimization"],
					"optimize-modules": [0.74, "module optimization"],
					"optimize-modules-advanced": [0.75, "advanced module optimization"],
					"optimize-chunks-basic": [0.76, "basic chunk optimization"],
					"optimize-chunks": [0.77, "chunk optimization"],
					"optimize-chunks-advanced": [0.78, "advanced chunk optimization"],
					// optimize-tree
					"revive-modules": [0.80, "module reviving"],
					"optimize-module-order": [0.81, "module order optimization"],
					"optimize-module-ids": [0.82, "module id optimization"],
					"revive-chunks": [0.83, "chunk reviving"],
					"optimize-chunk-order": [0.84, "chunk order optimization"],
					"optimize-chunk-ids": [0.85, "chunk id optimization"],
					"before-hash": [0.86, "hashing"],
					"before-module-assets": [0.87, "module assets processing"],
					"before-chunk-assets": [0.88, "chunk assets processing"],
					"additional-chunk-assets": [0.89, "additional chunk assets processing"],
					"record": [0.90, "recording"]
				};
				Object.keys(syncHooks).forEach(name => {
					let pass = 0;
					const settings = syncHooks[name];
					compilation.plugin(name, () => {
						if(pass++ > 0)
							handler(settings[0], settings[1], `pass ${pass}`);
						else
							handler(settings[0], settings[1]);
					});
				});
				compilation.plugin("optimize-tree", (chunks, modules, callback) => {
					handler(0.79, "module and chunk tree optimization");
					callback();
				});
				compilation.plugin("additional-assets", callback => {
					handler(0.91, "additional asset processing");
					callback();
				});
				compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
					handler(0.92, "chunk asset optimization");
					callback();
				});
				compilation.plugin("optimize-assets", (assets, callback) => {
					handler(0.94, "asset optimization");
					callback();
				});
			});
			compiler.plugin("emit", (compilation, callback) => {
				handler(0.95, "emitting");
				callback();
			});
			compiler.plugin("done", () => {
				handler(1, "");
			});
		}
 
		let lineCaretPosition = 0,
			lastState, lastStateTime;
 
		function defaultHandler(percentage, msg) {
			let state = msg;
			const details = Array.prototype.slice.call(arguments, 2);
			if(percentage < 1) {
				percentage = Math.floor(percentage * 100);
				msg = `${percentage}% ${msg}`;
				if(percentage < 100) {
					msg = ` ${msg}`;
				}
				if(percentage < 10) {
					msg = ` ${msg}`;
				}
				details.forEach(detail => {
					if(!detail) return;
					if(detail.length > 40) {
						detail = `...${detail.substr(detail.length - 37)}`;
					}
					msg += ` ${detail}`;
				});
			}
			if(profile) {
				state = state.replace(/^\d+\/\d+\s+/, "");
				if(percentage === 0) {
					lastState = null;
					lastStateTime = +new Date();
				} else if(state !== lastState || percentage === 1) {
					const now = +new Date();
					if(lastState) {
						const stateMsg = `${now - lastStateTime}ms ${lastState}`;
						goToLineStart(stateMsg);
						process.stderr.write(stateMsg + "\n");
						lineCaretPosition = 0;
					}
					lastState = state;
					lastStateTime = now;
				}
			}
			goToLineStart(msg);
			process.stderr.write(msg);
		}
 
		function goToLineStart(nextMessage) {
			let str = "";
			for(; lineCaretPosition > nextMessage.length; lineCaretPosition--) {
				str += "\b \b";
			}
			for(var i = 0; i < lineCaretPosition; i++) {
				str += "\b";
			}
			lineCaretPosition = nextMessage.length;
			if(str) process.stderr.write(str);
		}
	}
}
module.exports = ProgressPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ProvidePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/ProvidePlugin.js

Statements: 12.9% (4 / 31)      Branches: 0% (0 / 10)      Functions: 0% (0 / 3)      Lines: 13.33% (4 / 30)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57            1 1   1                                                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ParserHelpers = require("./ParserHelpers");
const ConstDependency = require("./dependencies/ConstDependency");
 
const NullFactory = require("./NullFactory");
 
class ProvidePlugin {
	constructor(definitions) {
		this.definitions = definitions;
	}
 
	apply(compiler) {
		const definitions = this.definitions;
		compiler.plugin("compilation", (compilation, params) => {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
				Object.keys(definitions).forEach(name => {
					var request = [].concat(definitions[name]);
					var splittedName = name.split(".");
					if(splittedName.length > 0) {
						splittedName.slice(1).forEach((_, i) => {
							const name = splittedName.slice(0, i + 1).join(".");
							parser.plugin(`can-rename ${name}`, ParserHelpers.approve);
						});
					}
					parser.plugin(`expression ${name}`, function(expr) {
						let nameIdentifier = name;
						const scopedName = name.indexOf(".") >= 0;
						let expression = `require(${JSON.stringify(request[0])})`;
						if(scopedName) {
							nameIdentifier = `__webpack_provided_${name.replace(/\./g, "_dot_")}`;
						}
						if(request.length > 1) {
							expression += request.slice(1).map(r => `[${JSON.stringify(r)}]`).join("");
						}
						if(!ParserHelpers.addParsedVariableToModule(this, nameIdentifier, expression)) {
							return false;
						}
						if(scopedName) {
							ParserHelpers.toConstantDependency(nameIdentifier).bind(this)(expr);
						}
						return true;
					});
				});
			});
		});
	}
}
module.exports = ProvidePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RawModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RawModule.js

Statements: 21.05% (4 / 19)      Branches: 0% (0 / 6)      Functions: 0% (0 / 7)      Lines: 21.05% (4 / 19)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52            1 1 1   1                                                                                  
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Module = require("./Module");
const OriginalSource = require("webpack-sources").OriginalSource;
const RawSource = require("webpack-sources").RawSource;
 
module.exports = class RawModule extends Module {
 
	constructor(source, identifier, readableIdentifier) {
		super();
		this.sourceStr = source;
		this.identifierStr = identifier || this.sourceStr;
		this.readableIdentifierStr = readableIdentifier || this.identifierStr;
		this.cacheable = true;
		this.built = false;
	}
 
	identifier() {
		return this.identifierStr;
	}
 
	size() {
		return this.sourceStr.length;
	}
 
	readableIdentifier(requestShortener) {
		return requestShortener.shorten(this.readableIdentifierStr);
	}
 
	needRebuild() {
		return false;
	}
 
	build(options, compilations, resolver, fs, callback) {
		this.builtTime = new Date().getTime();
		callback();
	}
 
	source() {
		if(this.useSourceMap)
			return new OriginalSource(this.sourceStr, this.identifier());
		else
			return new RawSource(this.sourceStr);
	}
 
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RecordIdsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RecordIdsPlugin.js

Statements: 2.73% (3 / 110)      Branches: 0% (0 / 54)      Functions: 0% (0 / 6)      Lines: 3.57% (3 / 84)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119            1                                                                     1                                                                                                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const identifierUtils = require("./util/identifier");
 
class RecordIdsPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", compilation => {
			compilation.plugin("record-modules", (modules, records) => {
				if(!records.modules) records.modules = {};
				if(!records.modules.byIdentifier) records.modules.byIdentifier = {};
				if(!records.modules.usedIds) records.modules.usedIds = {};
				modules.forEach(function(module) {
					if(!module.portableId) module.portableId = identifierUtils.makePathsRelative(compiler.context, module.identifier());
					const identifier = module.portableId;
					records.modules.byIdentifier[identifier] = module.id;
					records.modules.usedIds[module.id] = module.id;
				});
			});
			compilation.plugin("revive-modules", (modules, records) => {
				if(!records.modules) return;
				if(records.modules.byIdentifier) {
					const usedIds = {};
					modules.forEach(function(module) {
						if(module.id !== null) return;
						if(!module.portableId) module.portableId = identifierUtils.makePathsRelative(compiler.context, module.identifier());
						const identifier = module.portableId;
						const id = records.modules.byIdentifier[identifier];
						if(id === undefined) return;
						if(usedIds[id]) return;
						usedIds[id] = true;
						module.id = id;
					});
				}
				compilation.usedModuleIds = records.modules.usedIds;
			});
 
			function getDepBlockIdent(chunk, block) {
				const ident = [];
				if(block.chunks.length > 1)
					ident.push(block.chunks.indexOf(chunk));
				while(block.parent) {
					const p = block.parent;
					const idx = p.blocks.indexOf(block);
					const l = p.blocks.length - 1;
					ident.unshift(`${idx}/${l}`);
					block = block.parent;
				}
				if(!block.identifier) return null;
				ident.unshift(identifierUtils.makePathsRelative(compiler.context, block.identifier()));
				return ident.join(":");
			}
			compilation.plugin("record-chunks", (chunks, records) => {
				records.nextFreeChunkId = compilation.nextFreeChunkId;
				if(!records.chunks) records.chunks = {};
				if(!records.chunks.byName) records.chunks.byName = {};
				if(!records.chunks.byBlocks) records.chunks.byBlocks = {};
				records.chunks.usedIds = {};
				chunks.forEach(chunk => {
					const name = chunk.name;
					const blockIdents = chunk.blocks.map(getDepBlockIdent.bind(null, chunk)).filter(Boolean);
					if(name) records.chunks.byName[name] = chunk.id;
					blockIdents.forEach((blockIdent) => {
						records.chunks.byBlocks[blockIdent] = chunk.id;
					});
					records.chunks.usedIds[chunk.id] = chunk.id;
				});
			});
			compilation.plugin("revive-chunks", (chunks, records) => {
				if(!records.chunks) return;
				const usedIds = {};
				if(records.chunks.byName) {
					chunks.forEach(function(chunk) {
						if(chunk.id !== null) return;
						if(!chunk.name) return;
						const id = records.chunks.byName[chunk.name];
						if(id === undefined) return;
						if(usedIds[id]) return;
						usedIds[id] = true;
						chunk.id = id;
					});
				}
				if(records.chunks.byBlocks) {
					const argumentedChunks = chunks.filter(chunk => chunk.id === null).map(chunk => ({
						chunk,
						blockIdents: chunk.blocks.map(getDepBlockIdent.bind(null, chunk)).filter(Boolean)
					})).filter(arg => arg.blockIdents.length > 0);
					let blockIdentsCount = {};
					argumentedChunks.forEach((arg, idx) => {
						arg.blockIdents.forEach(blockIdent => {
							const id = records.chunks.byBlocks[blockIdent];
							if(typeof id !== "number") return;
							const accessor = `${id}:${idx}`;
							blockIdentsCount[accessor] = (blockIdentsCount[accessor] || 0) + 1;
						});
					});
					blockIdentsCount = Object.keys(blockIdentsCount).map(accessor => [blockIdentsCount[accessor]].concat(accessor.split(":").map(Number))).sort((a, b) => b[0] - a[0]);
					blockIdentsCount.forEach(function(arg) {
						const id = arg[1];
						if(usedIds[id]) return;
						const idx = arg[2];
						const chunk = argumentedChunks[idx].chunk;
						if(chunk.id !== null) return;
						usedIds[id] = true;
						chunk.id = id;
					});
				}
				compilation.usedChunkIds = records.chunks.usedIds;
			});
		});
	}
}
module.exports = RecordIdsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RequestShortener.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RequestShortener.js

Statements: 5.56% (2 / 36)      Branches: 0% (0 / 28)      Functions: 0% (0 / 2)      Lines: 5.88% (2 / 34)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58            1                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
 
class RequestShortener {
	constructor(directory) {
		directory = directory.replace(/\\/g, "/");
		if(/[\/\\]$/.test(directory)) directory = directory.substr(0, directory.length - 1);
 
		if(directory) {
			const currentDirectoryRegExpString = directory.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
			this.currentDirectoryRegExp = new RegExp("^" + currentDirectoryRegExpString + "|(!)" + currentDirectoryRegExpString, "g");
		}
 
		const dirname = path.dirname(directory);
		const endsWithSeperator = /[\/\\]$/.test(dirname);
		const parentDirectory = endsWithSeperator ? dirname.substr(0, dirname.length - 1) : dirname;
		if(parentDirectory && parentDirectory !== directory) {
			const parentDirectoryRegExpString = parentDirectory.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
			this.parentDirectoryRegExp = new RegExp("^" + parentDirectoryRegExpString + "|(!)" + parentDirectoryRegExpString, "g");
		}
 
		if(__dirname.length >= 2) {
			const buildins = path.join(__dirname, "..").replace(/\\/g, "/");
			const buildinsAsModule = this.currentDirectoryRegExp && this.currentDirectoryRegExp.test(buildins);
			this.buildinsAsModule = buildinsAsModule;
			const buildinsRegExpString = buildins.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
			this.buildinsRegExp = new RegExp("^" + buildinsRegExpString + "|(!)" + buildinsRegExpString, "g");
		}
 
		this.nodeModulesRegExp = /\/node_modules\//g;
		this.indexJsRegExp = /\/index.js(!|\?|\(query\))/g;
	}
 
	shorten(request) {
		if(!request) return request;
		request = request.replace(/\\/g, "/");
		if(this.buildinsAsModule && this.buildinsRegExp)
			request = request.replace(this.buildinsRegExp, "!(webpack)");
		if(this.currentDirectoryRegExp)
			request = request.replace(this.currentDirectoryRegExp, "!.");
		if(this.parentDirectoryRegExp)
			request = request.replace(this.parentDirectoryRegExp, "!..");
		if(!this.buildinsAsModule && this.buildinsRegExp)
			request = request.replace(this.buildinsRegExp, "!(webpack)");
		request = request.replace(this.nodeModulesRegExp, "/~/");
		request = request.replace(this.indexJsRegExp, "$1");
		return request.replace(/^!|!$/, "");
	}
}
 
module.exports = RequestShortener;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RequireJsStuffPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RequireJsStuffPlugin.js

Statements: 28.57% (4 / 14)      Branches: 0% (0 / 4)      Functions: 0% (0 / 3)      Lines: 28.57% (4 / 14)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            1 1 1   1                                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ParserHelpers = require("./ParserHelpers");
const ConstDependency = require("./dependencies/ConstDependency");
const NullFactory = require("./NullFactory");
 
module.exports = class RequireJsStuffPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", function(compilation, params) {
			compilation.dependencyFactories.set(ConstDependency, new NullFactory());
			compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
			params.normalModuleFactory.plugin("parser", function(parser, parserOptions) {
 
				if(typeof parserOptions.requireJs !== "undefined" && !parserOptions.requireJs)
					return;
 
				parser.plugin("call require.config", ParserHelpers.toConstantDependency("undefined"));
				parser.plugin("call requirejs.config", ParserHelpers.toConstantDependency("undefined"));
 
				parser.plugin("expression require.version", ParserHelpers.toConstantDependency(JSON.stringify("0.0.0")));
				parser.plugin("expression requirejs.onError", ParserHelpers.toConstantDependency(JSON.stringify("__webpack_require__.oe")));
			});
		});
	}
 
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RuleSet.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/RuleSet.js

Statements: 2.9% (6 / 207)      Branches: 0% (0 / 174)      Functions: 0% (0 / 22)      Lines: 2.96% (6 / 203)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446                                                                                                                                                        1                                                                                                                                                                                                                                                     1           1                                                                                                                                                                                                                                                                                                                                                                                                                                           1           1                   1                    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
/*
<rules>: <rule>
<rules>: [<rule>]
<rule>: {
	resource: {
		test: <condition>,
		include: <condition>,
		exclude: <condition>,
	},
	resource: <condition>, -> resource.test
	test: <condition>, -> resource.test
	include: <condition>, -> resource.include
	exclude: <condition>, -> resource.exclude
	resourceQuery: <condition>,
	compiler: <condition>,
	issuer: <condition>,
	use: "loader", -> use[0].loader
	loader: <>, -> use[0].loader
	loaders: <>, -> use
	options: {}, -> use[0].options,
	query: {}, -> options
	parser: {},
	use: [
		"loader" -> use[x].loader
	],
	use: [
		{
			loader: "loader",
			options: {}
		}
	],
	rules: [
		<rule>
	],
	oneOf: [
		<rule>
	]
}
 
<condition>: /regExp/
<condition>: function(arg) {}
<condition>: "starting"
<condition>: [<condition>] // or
<condition>: { and: [<condition>] }
<condition>: { or: [<condition>] }
<condition>: { not: [<condition>] }
<condition>: { test: <condition>, include: <condition>, exclude: <condition> }
 
 
normalized:
 
{
	resource: function(),
	resourceQuery: function(),
	compiler: function(),
	issuer: function(),
	use: [
		{
			loader: string,
			options: string,
			<any>: <any>
		}
	],
	rules: [<rule>],
	oneOf: [<rule>],
	<any>: <any>,
}
 
*/
 
"use strict";
 
module.exports = class RuleSet {
	constructor(rules) {
		this.references = Object.create(null);
		this.rules = RuleSet.normalizeRules(rules, this.references, "ref-");
	}
 
	static normalizeRules(rules, refs, ident) {
		if(Array.isArray(rules)) {
			return rules.map((rule, idx) => {
				return RuleSet.normalizeRule(rule, refs, `${ident}-${idx}`);
			});
		} else if(rules) {
			return [RuleSet.normalizeRule(rules, refs, ident)];
		} else {
			return [];
		}
	}
 
	static normalizeRule(rule, refs, ident) {
		if(typeof rule === "string")
			return {
				use: [{
					loader: rule
				}]
			};
		if(!rule)
			throw new Error("Unexcepted null when object was expected as rule");
		if(typeof rule !== "object")
			throw new Error("Unexcepted " + typeof rule + " when object was expected as rule (" + rule + ")");
 
		let newRule = {};
		let useSource;
		let resourceSource;
		let condition;
 
		if(rule.test || rule.include || rule.exclude) {
			checkResourceSource("test + include + exclude");
			condition = {
				test: rule.test,
				include: rule.include,
				exclude: rule.exclude
			};
			try {
				newRule.resource = RuleSet.normalizeCondition(condition);
			} catch(error) {
				throw new Error(RuleSet.buildErrorMessage(condition, error));
			}
		}
 
		if(rule.resource) {
			checkResourceSource("resource");
			try {
				newRule.resource = RuleSet.normalizeCondition(rule.resource);
			} catch(error) {
				throw new Error(RuleSet.buildErrorMessage(rule.resource, error));
			}
		}
 
		if(rule.resourceQuery) {
			try {
				newRule.resourceQuery = RuleSet.normalizeCondition(rule.resourceQuery);
			} catch(error) {
				throw new Error(RuleSet.buildErrorMessage(rule.resourceQuery, error));
			}
		}
 
		if(rule.compiler) {
			try {
				newRule.compiler = RuleSet.normalizeCondition(rule.compiler);
			} catch(error) {
				throw new Error(RuleSet.buildErrorMessage(rule.compiler, error));
			}
		}
 
		if(rule.issuer) {
			try {
				newRule.issuer = RuleSet.normalizeCondition(rule.issuer);
			} catch(error) {
				throw new Error(RuleSet.buildErrorMessage(rule.issuer, error));
			}
		}
 
		if(rule.loader && rule.loaders)
			throw new Error(RuleSet.buildErrorMessage(rule, new Error("Provided loader and loaders for rule (use only one of them)")));
 
		const loader = rule.loaders || rule.loader;
		if(typeof loader === "string" && !rule.options && !rule.query) {
			checkUseSource("loader");
			newRule.use = RuleSet.normalizeUse(loader.split("!"), ident);
		} else if(typeof loader === "string" && (rule.options || rule.query)) {
			checkUseSource("loader + options/query");
			newRule.use = RuleSet.normalizeUse({
				loader: loader,
				options: rule.options,
				query: rule.query
			}, ident);
		} else if(loader && (rule.options || rule.query)) {
			throw new Error(RuleSet.buildErrorMessage(rule, new Error("options/query cannot be used with loaders (use options for each array item)")));
		} else if(loader) {
			checkUseSource("loaders");
			newRule.use = RuleSet.normalizeUse(loader, ident);
		} else if(rule.options || rule.query) {
			throw new Error(RuleSet.buildErrorMessage(rule, new Error("options/query provided without loader (use loader + options)")));
		}
 
		if(rule.use) {
			checkUseSource("use");
			newRule.use = RuleSet.normalizeUse(rule.use, ident);
		}
 
		if(rule.rules)
			newRule.rules = RuleSet.normalizeRules(rule.rules, refs, `${ident}-rules`);
 
		if(rule.oneOf)
			newRule.oneOf = RuleSet.normalizeRules(rule.oneOf, refs, `${ident}-oneOf`);
 
		const keys = Object.keys(rule).filter((key) => {
			return ["resource", "resourceQuery", "compiler", "test", "include", "exclude", "issuer", "loader", "options", "query", "loaders", "use", "rules", "oneOf"].indexOf(key) < 0;
		});
		keys.forEach((key) => {
			newRule[key] = rule[key];
		});
 
		function checkUseSource(newSource) {
			if(useSource && useSource !== newSource)
				throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one result source (provided " + newSource + " and " + useSource + ")")));
			useSource = newSource;
		}
 
		function checkResourceSource(newSource) {
			if(resourceSource && resourceSource !== newSource)
				throw new Error(RuleSet.buildErrorMessage(rule, new Error("Rule can only have one resource source (provided " + newSource + " and " + resourceSource + ")")));
			resourceSource = newSource;
		}
 
		if(Array.isArray(newRule.use)) {
			newRule.use.forEach((item) => {
				if(item.ident) {
					refs[item.ident] = item.options;
				}
			});
		}
 
		return newRule;
	}
 
	static buildErrorMessage(condition, error) {
		const conditionAsText = JSON.stringify(condition, (key, value) => {
			return value === undefined ? "undefined" : value;
		}, 2);
		return error.message + " in " + conditionAsText;
	}
 
	static normalizeUse(use, ident) {
		if(Array.isArray(use)) {
			return use
				.map((item, idx) => RuleSet.normalizeUse(item, `${ident}-${idx}`))
				.reduce((arr, items) => arr.concat(items), []);
		}
		return [RuleSet.normalizeUseItem(use, ident)];
	}
 
	static normalizeUseItemFunction(use, data) {
		const result = use(data);
		if(typeof result === "string") {
			return RuleSet.normalizeUseItem(result);
		}
		return result;
	}
 
	static normalizeUseItemString(useItemString) {
		const idx = useItemString.indexOf("?");
		if(idx >= 0) {
			return {
				loader: useItemString.substr(0, idx),
				options: useItemString.substr(idx + 1)
			};
		}
		return {
			loader: useItemString
		};
	}
 
	static normalizeUseItem(item, ident) {
		if(typeof item === "function")
			return item;
 
		if(typeof item === "string") {
			return RuleSet.normalizeUseItemString(item);
		}
 
		let newItem = {};
 
		if(item.options && item.query)
			throw new Error("Provided options and query in use");
 
		if(!item.loader)
			throw new Error("No loader specified");
 
		newItem.options = item.options || item.query;
 
		if(typeof newItem.options === "object" && newItem.options) {
			if(newItem.options.ident)
				newItem.ident = newItem.options.ident;
			else
				newItem.ident = ident;
		}
 
		const keys = Object.keys(item).filter(function(key) {
			return ["options", "query"].indexOf(key) < 0;
		});
 
		keys.forEach(function(key) {
			newItem[key] = item[key];
		});
 
		return newItem;
	}
 
	static normalizeCondition(condition) {
		if(!condition)
			throw new Error("Expected condition but got falsy value");
		if(typeof condition === "string") {
			return str => str.indexOf(condition) === 0;
		}
		if(typeof condition === "function") {
			return condition;
		}
		if(condition instanceof RegExp) {
			return condition.test.bind(condition);
		}
		if(Array.isArray(condition)) {
			const items = condition.map(c => RuleSet.normalizeCondition(c));
			return orMatcher(items);
		}
		if(typeof condition !== "object")
			throw Error("Unexcepted " + typeof condition + " when condition was expected (" + condition + ")");
 
		let matchers = [];
		Object.keys(condition).forEach(key => {
			const value = condition[key];
			switch(key) {
				case "or":
				case "include":
				case "test":
					if(value)
						matchers.push(RuleSet.normalizeCondition(value));
					break;
				case "and":
					if(value) {
						const items = value.map(c => RuleSet.normalizeCondition(c));
						matchers.push(andMatcher(items));
					}
					break;
				case "not":
				case "exclude":
					if(value) {
						const matcher = RuleSet.normalizeCondition(value);
						matchers.push(notMatcher(matcher));
					}
					break;
				default:
					throw new Error("Unexcepted property " + key + " in condition");
			}
		});
		if(matchers.length === 0)
			throw new Error("Excepted condition but got " + condition);
		if(matchers.length === 1)
			return matchers[0];
		return andMatcher(matchers);
	}
 
	exec(data) {
		const result = [];
		this._run(data, {
			rules: this.rules
		}, result);
		return result;
	}
 
	_run(data, rule, result) {
		// test conditions
		if(rule.resource && !data.resource)
			return false;
		if(rule.resourceQuery && !data.resourceQuery)
			return false;
		if(rule.compiler && !data.compiler)
			return false;
		if(rule.issuer && !data.issuer)
			return false;
		if(rule.resource && !rule.resource(data.resource))
			return false;
		if(data.issuer && rule.issuer && !rule.issuer(data.issuer))
			return false;
		if(data.resourceQuery && rule.resourceQuery && !rule.resourceQuery(data.resourceQuery))
			return false;
		if(data.compiler && rule.compiler && !rule.compiler(data.compiler))
			return false;
 
		// apply
		const keys = Object.keys(rule).filter((key) => {
			return ["resource", "resourceQuery", "compiler", "issuer", "rules", "oneOf", "use", "enforce"].indexOf(key) < 0;
		});
		keys.forEach((key) => {
			result.push({
				type: key,
				value: rule[key]
			});
		});
 
		if(rule.use) {
			rule.use.forEach((use) => {
				result.push({
					type: "use",
					value: typeof use === "function" ? RuleSet.normalizeUseItemFunction(use, data) : use,
					enforce: rule.enforce
				});
			});
		}
 
		if(rule.rules) {
			for(let i = 0; i < rule.rules.length; i++) {
				this._run(data, rule.rules[i], result);
			}
		}
 
		if(rule.oneOf) {
			for(let i = 0; i < rule.oneOf.length; i++) {
				if(this._run(data, rule.oneOf[i], result))
					break;
			}
		}
 
		return true;
	}
 
	findOptionsByIdent(ident) {
		const options = this.references[ident];
		if(!options) throw new Error("Can't find options with ident '" + ident + "'");
		return options;
	}
};
 
function notMatcher(matcher) {
	return function(str) {
		return !matcher(str);
	};
}
 
function orMatcher(items) {
	return function(str) {
		for(let i = 0; i < items.length; i++) {
			if(items[i](str))
				return true;
		}
		return false;
	};
}
 
function andMatcher(items) {
	return function(str) {
		for(let i = 0; i < items.length; i++) {
			if(!items[i](str))
				return false;
		}
		return true;
	};
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SetVarMainTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SetVarMainTemplatePlugin.js

Statements: 10.53% (2 / 19)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 11.11% (2 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43            1                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
 
class SetVarMainTemplatePlugin {
	constructor(varExpression, copyObject) {
		this.varExpression = varExpression;
		this.copyObject = copyObject;
	}
 
	apply(compilation) {
		const mainTemplate = compilation.mainTemplate;
		compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
			const varExpression = mainTemplate.applyPluginsWaterfall("asset-path", this.varExpression, {
				hash,
				chunk
			});
			if(this.copyObject) {
				return new ConcatSource(`(function(e, a) { for(var i in a) e[i] = a[i]; }(${varExpression}, `, source, "))");
			} else {
				const prefix = `${varExpression} =\n`;
				return new ConcatSource(prefix, source);
			}
		});
		mainTemplate.plugin("global-hash-paths", (paths) => {
			if(this.varExpression) paths.push(this.varExpression);
			return paths;
		});
		mainTemplate.plugin("hash", hash => {
			hash.update("set var");
			hash.update(`${this.varExpression}`);
			hash.update(`${this.copyObject}`);
		});
	}
}
 
module.exports = SetVarMainTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SingleEntryPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SingleEntryPlugin.js

Statements: 14.29% (2 / 14)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 14.29% (2 / 14)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37          1                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const SingleEntryDependency = require("./dependencies/SingleEntryDependency");
 
class SingleEntryPlugin {
	constructor(context, entry, name) {
		this.context = context;
		this.entry = entry;
		this.name = name;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(SingleEntryDependency, normalModuleFactory);
		});
 
		compiler.plugin("make", (compilation, callback) => {
			const dep = SingleEntryPlugin.createDependency(this.entry, this.name);
			compilation.addEntry(this.context, dep, this.name, callback);
		});
	}
 
	static createDependency(entry, name) {
		const dep = new SingleEntryDependency(entry);
		dep.loc = name;
		return dep;
	}
}
 
module.exports = SingleEntryPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SizeFormatHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SizeFormatHelpers.js

Statements: 28.57% (2 / 7)      Branches: 0% (0 / 2)      Functions: 100% (0 / 0)      Lines: 28.57% (2 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20            1   1                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Sean Larkin @thelarkinn
*/
"use strict";
 
const SizeFormatHelpers = exports;
 
SizeFormatHelpers.formatSize = size => {
	if(size <= 0) {
		return "0 bytes";
	}
 
	const abbreviations = ["bytes", "kB", "MB", "GB"];
	const index = Math.floor(Math.log(size) / Math.log(1000));
 
	return `${+(size / Math.pow(1000, index)).toPrecision(3)} ${abbreviations[index]}`;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SourceMapDevToolModuleOptionsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SourceMapDevToolModuleOptionsPlugin.js

Statements: 10.53% (2 / 19)      Branches: 0% (0 / 10)      Functions: 0% (0 / 2)      Lines: 11.76% (2 / 17)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » SourceMapDevToolModuleOptionsPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39            1                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
 
class SourceMapDevToolModuleOptionsPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compilation) {
		const options = this.options;
		if(options.module !== false) {
			compilation.plugin("build-module", module => {
				module.useSourceMap = true;
			});
		}
		if(options.lineToLine === true) {
			compilation.plugin("build-module", module => {
				module.lineToLine = true;
			});
		} else if(options.lineToLine) {
			compilation.plugin("build-module", module => {
				if(!module.resource) return;
				let resourcePath = module.resource;
				const idx = resourcePath.indexOf("?");
				if(idx >= 0) resourcePath = resourcePath.substr(0, idx);
				module.lineToLine = ModuleFilenameHelpers.matchObject(options.lineToLine, resourcePath);
			});
		}
	}
}
 
module.exports = SourceMapDevToolModuleOptionsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SourceMapDevToolPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/SourceMapDevToolPlugin.js

Statements: 6.96% (8 / 115)      Branches: 0% (0 / 54)      Functions: 0% (0 / 6)      Lines: 7.27% (8 / 110)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168            1 1 1 1 1 1   1                                                                                                                                                                                                                                                                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
const RequestShortener = require("./RequestShortener");
const ConcatSource = require("webpack-sources").ConcatSource;
const RawSource = require("webpack-sources").RawSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
 
const basename = (name) => {
	if(name.indexOf("/") < 0) return name;
	return name.substr(name.lastIndexOf("/") + 1);
};
 
class SourceMapDevToolPlugin {
	constructor(options) {
		if(arguments.length > 1)
			throw new Error("SourceMapDevToolPlugin only takes one argument (pass an options object)");
		// TODO: remove in webpack 3
		if(typeof options === "string") {
			options = {
				sourceMapFilename: options
			};
		}
		if(!options) options = {};
		this.sourceMapFilename = options.filename;
		this.sourceMappingURLComment = options.append === false ? false : options.append || "\n//# sourceMappingURL=[url]";
		this.moduleFilenameTemplate = options.moduleFilenameTemplate || "webpack:///[resourcePath]";
		this.fallbackModuleFilenameTemplate = options.fallbackModuleFilenameTemplate || "webpack:///[resourcePath]?[hash]";
		this.options = options;
	}
 
	apply(compiler) {
		const sourceMapFilename = this.sourceMapFilename;
		const sourceMappingURLComment = this.sourceMappingURLComment;
		const moduleFilenameTemplate = this.moduleFilenameTemplate;
		const fallbackModuleFilenameTemplate = this.fallbackModuleFilenameTemplate;
		const requestShortener = new RequestShortener(compiler.context);
		const options = this.options;
		options.test = options.test || /\.(js|css)($|\?)/i;
		compiler.plugin("compilation", compilation => {
			new SourceMapDevToolModuleOptionsPlugin(options).apply(compilation);
			compilation.plugin("after-optimize-chunk-assets", function(chunks) {
				let allModules = [];
				let allModuleFilenames = [];
				const tasks = [];
				chunks.forEach(function(chunk) {
					chunk.files.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options)).map(function(file) {
						const asset = compilation.assets[file];
						if(asset.__SourceMapDevToolFile === file && asset.__SourceMapDevToolData) {
							const data = asset.__SourceMapDevToolData;
							for(const cachedFile in data) {
								compilation.assets[cachedFile] = data[cachedFile];
								if(cachedFile !== file)
									chunk.files.push(cachedFile);
							}
							return;
						}
						let source, sourceMap;
						if(asset.sourceAndMap) {
							const sourceAndMap = asset.sourceAndMap(options);
							sourceMap = sourceAndMap.map;
							source = sourceAndMap.source;
						} else {
							sourceMap = asset.map(options);
							source = asset.source();
						}
						if(sourceMap) {
							return {
								chunk,
								file,
								asset,
								source,
								sourceMap
							};
						}
					}).filter(Boolean).map(task => {
						const modules = task.sourceMap.sources.map(source => {
							const module = compilation.findModule(source);
							return module || source;
						});
						const moduleFilenames = modules.map(module => ModuleFilenameHelpers.createFilename(module, moduleFilenameTemplate, requestShortener));
						task.modules = modules;
						task.moduleFilenames = moduleFilenames;
						return task;
					}).forEach(task => {
						allModules = allModules.concat(task.modules);
						allModuleFilenames = allModuleFilenames.concat(task.moduleFilenames);
						tasks.push(task);
					});
				});
				allModuleFilenames = ModuleFilenameHelpers.replaceDuplicates(allModuleFilenames, (filename, i) => ModuleFilenameHelpers.createFilename(allModules[i], fallbackModuleFilenameTemplate, requestShortener), (ai, bi) => {
					let a = allModules[ai];
					let b = allModules[bi];
					a = !a ? "" : typeof a === "string" ? a : a.identifier();
					b = !b ? "" : typeof b === "string" ? b : b.identifier();
					return a.length - b.length;
				});
				allModuleFilenames = ModuleFilenameHelpers.replaceDuplicates(allModuleFilenames, (filename, i, n) => {
					for(let j = 0; j < n; j++)
						filename += "*";
					return filename;
				});
				tasks.forEach(task => {
					task.moduleFilenames = allModuleFilenames.slice(0, task.moduleFilenames.length);
					allModuleFilenames = allModuleFilenames.slice(task.moduleFilenames.length);
				});
				tasks.forEach(function(task) {
					const chunk = task.chunk;
					const file = task.file;
					const asset = task.asset;
					const sourceMap = task.sourceMap;
					const source = task.source;
					const moduleFilenames = task.moduleFilenames;
					const modules = task.modules;
					sourceMap.sources = moduleFilenames;
					if(sourceMap.sourcesContent && !options.noSources) {
						sourceMap.sourcesContent = sourceMap.sourcesContent.map((content, i) => `${content}\n\n\n${ModuleFilenameHelpers.createFooter(modules[i], requestShortener)}`);
					} else {
						sourceMap.sourcesContent = undefined;
					}
					sourceMap.sourceRoot = options.sourceRoot || "";
					sourceMap.file = file;
					asset.__SourceMapDevToolFile = file;
					asset.__SourceMapDevToolData = {};
					let currentSourceMappingURLComment = sourceMappingURLComment;
					if(currentSourceMappingURLComment !== false && /\.css($|\?)/i.test(file)) {
						currentSourceMappingURLComment = currentSourceMappingURLComment.replace(/^\n\/\/(.*)$/, "\n/*$1*/");
					}
					if(sourceMapFilename) {
						let filename = file;
						let query = "";
						const idx = filename.indexOf("?");
						if(idx >= 0) {
							query = filename.substr(idx);
							filename = filename.substr(0, idx);
						}
						const sourceMapFile = compilation.getPath(sourceMapFilename, {
							chunk,
							filename,
							query,
							basename: basename(filename)
						});
						const sourceMapUrl = path.relative(path.dirname(file), sourceMapFile).replace(/\\/g, "/");
						if(currentSourceMappingURLComment !== false) {
							asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment.replace(/\[url\]/g, sourceMapUrl));
						}
						asset.__SourceMapDevToolData[sourceMapFile] = compilation.assets[sourceMapFile] = new RawSource(JSON.stringify(sourceMap));
						chunk.files.push(sourceMapFile);
					} else {
						asset.__SourceMapDevToolData[file] = compilation.assets[file] = new ConcatSource(new RawSource(source), currentSourceMappingURLComment
							.replace(/\[map\]/g, () => JSON.stringify(sourceMap))
							.replace(/\[url\]/g, () => `data:application/json;charset=utf-8;base64,${new Buffer(JSON.stringify(sourceMap), "utf-8").toString("base64")}`) // eslint-disable-line
						);
					}
				});
			});
		});
	}
}
 
module.exports = SourceMapDevToolPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Stats.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Stats.js

Statements: 1.12% (6 / 537)      Branches: 0% (0 / 379)      Functions: 0% (0 / 12)      Lines: 1.19% (6 / 505)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896            1 1 1   1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequestShortener = require("./RequestShortener");
const SizeFormatHelpers = require("./SizeFormatHelpers");
const formatLocation = require("./formatLocation");
 
const optionOrFallback = (optionValue, fallbackValue) => optionValue !== undefined ? optionValue : fallbackValue;
 
class Stats {
	constructor(compilation) {
		this.compilation = compilation;
		this.hash = compilation.hash;
	}
 
	static filterWarnings(warnings, warningsFilter) {
		// we dont have anything to filter so all warnings can be shown
		if(!warningsFilter) {
			return warnings;
		}
 
		// create a chain of filters
		// if they return "true" a warning should be surpressed
		const normalizedWarningsFilters = [].concat(warningsFilter).map(filter => {
			if(typeof filter === "string") {
				return warning => warning.indexOf(filter) > -1;
			}
 
			if(filter instanceof RegExp) {
				return warning => filter.test(warning);
			}
 
			if(typeof filter === "function") {
				return filter;
			}
 
			throw new Error(`Can only filter warnings with Strings or RegExps. (Given: ${filter})`);
		});
		return warnings.filter(warning => {
			return !normalizedWarningsFilters.some(check => check(warning));
		});
	}
 
	hasWarnings() {
		return this.compilation.warnings.length > 0;
	}
 
	hasErrors() {
		return this.compilation.errors.length > 0;
	}
 
	// remove a prefixed "!" that can be specified to reverse sort order
	normalizeFieldKey(field) {
		if(field[0] === "!") {
			return field.substr(1);
		}
		return field;
	}
 
	// if a field is prefixed by a "!" reverse sort order
	sortOrderRegular(field) {
		if(field[0] === "!") {
			return false;
		}
		return true;
	}
 
	toJson(options, forToString) {
		if(typeof options === "boolean" || typeof options === "string") {
			options = Stats.presetToOptions(options);
		} else if(!options) {
			options = {};
		}
 
		const compilation = this.compilation;
		const requestShortener = new RequestShortener(optionOrFallback(options.context, process.cwd()));
		const showPerformance = optionOrFallback(options.performance, true);
		const showHash = optionOrFallback(options.hash, true);
		const showVersion = optionOrFallback(options.version, true);
		const showTimings = optionOrFallback(options.timings, true);
		const showAssets = optionOrFallback(options.assets, true);
		const showEntrypoints = optionOrFallback(options.entrypoints, !forToString);
		const showChunks = optionOrFallback(options.chunks, true);
		const showChunkModules = optionOrFallback(options.chunkModules, !!forToString);
		const showChunkOrigins = optionOrFallback(options.chunkOrigins, !forToString);
		const showModules = optionOrFallback(options.modules, !forToString);
		const showDepth = optionOrFallback(options.depth, !forToString);
		const showCachedModules = optionOrFallback(options.cached, true);
		const showCachedAssets = optionOrFallback(options.cachedAssets, true);
		const showReasons = optionOrFallback(options.reasons, !forToString);
		const showUsedExports = optionOrFallback(options.usedExports, !forToString);
		const showProvidedExports = optionOrFallback(options.providedExports, !forToString);
		const showChildren = optionOrFallback(options.children, true);
		const showSource = optionOrFallback(options.source, !forToString);
		const showErrors = optionOrFallback(options.errors, true);
		const showErrorDetails = optionOrFallback(options.errorDetails, !forToString);
		const showWarnings = optionOrFallback(options.warnings, true);
		const warningsFilter = optionOrFallback(options.warningsFilter, null);
		const showPublicPath = optionOrFallback(options.publicPath, !forToString);
		const excludeModules = [].concat(optionOrFallback(options.exclude, [])).map(str => {
			if(typeof str !== "string") return str;
			return new RegExp(`[\\\\/]${str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&")}([\\\\/]|$|!|\\?)`);
		});
		const maxModules = optionOrFallback(options.maxModules, forToString ? 15 : Infinity);
		const sortModules = optionOrFallback(options.modulesSort, "id");
		const sortChunks = optionOrFallback(options.chunksSort, "id");
		const sortAssets = optionOrFallback(options.assetsSort, "");
 
		const createModuleFilter = () => {
			let i = 0;
			return module => {
				if(!showCachedModules && !module.built) {
					return false;
				}
				if(excludeModules.length > 0) {
					const ident = requestShortener.shorten(module.resource);
					const excluded = excludeModules.some(regExp => regExp.test(ident));
					if(excluded)
						return false;
				}
				return i++ < maxModules;
			};
		};
 
		const sortByFieldAndOrder = (fieldKey, a, b) => {
			if(a[fieldKey] === null && b[fieldKey] === null) return 0;
			if(a[fieldKey] === null) return 1;
			if(b[fieldKey] === null) return -1;
			if(a[fieldKey] === b[fieldKey]) return 0;
			return a[fieldKey] < b[fieldKey] ? -1 : 1;
		};
 
		const sortByField = (field) => (a, b) => {
			if(!field) {
				return 0;
			}
 
			const fieldKey = this.normalizeFieldKey(field);
 
			// if a field is prefixed with a "!" the sort is reversed!
			const sortIsRegular = this.sortOrderRegular(field);
 
			return sortByFieldAndOrder(fieldKey, sortIsRegular ? a : b, sortIsRegular ? b : a);
		};
 
		const formatError = (e) => {
			let text = "";
			if(typeof e === "string")
				e = {
					message: e
				};
			if(e.chunk) {
				text += `chunk ${e.chunk.name || e.chunk.id}${e.chunk.hasRuntime() ? " [entry]" : e.chunk.isInitial() ? " [initial]" : ""}\n`;
			}
			if(e.file) {
				text += `${e.file}\n`;
			}
			if(e.module && e.module.readableIdentifier && typeof e.module.readableIdentifier === "function") {
				text += `${e.module.readableIdentifier(requestShortener)}\n`;
			}
			text += e.message;
			if(showErrorDetails && e.details) text += `\n${e.details}`;
			if(showErrorDetails && e.missing) text += e.missing.map(item => `\n[${item}]`).join("");
			if(e.dependencies && e.origin) {
				text += `\n @ ${e.origin.readableIdentifier(requestShortener)}`;
				e.dependencies.forEach(dep => {
					if(!dep.loc) return;
					if(typeof dep.loc === "string") return;
					const locInfo = formatLocation(dep.loc);
					if(!locInfo) return;
					text += ` ${locInfo}`;
				});
				let current = e.origin;
				while(current.issuer) {
					current = current.issuer;
					text += `\n @ ${current.readableIdentifier(requestShortener)}`;
				}
			}
			return text;
		};
 
		const obj = {
			errors: compilation.errors.map(formatError),
			warnings: Stats.filterWarnings(compilation.warnings.map(formatError), warningsFilter)
		};
 
		//We just hint other renderers since actually omitting
		//errors/warnings from the JSON would be kind of weird.
		Object.defineProperty(obj, "_showWarnings", {
			value: showWarnings,
			enumerable: false
		});
		Object.defineProperty(obj, "_showErrors", {
			value: showErrors,
			enumerable: false
		});
 
		if(showVersion) {
			obj.version = require("../package.json").version;
		}
 
		if(showHash) obj.hash = this.hash;
		if(showTimings && this.startTime && this.endTime) {
			obj.time = this.endTime - this.startTime;
		}
		if(compilation.needAdditionalPass) {
			obj.needAdditionalPass = true;
		}
		if(showPublicPath) {
			obj.publicPath = this.compilation.mainTemplate.getPublicPath({
				hash: this.compilation.hash
			});
		}
		if(showAssets) {
			const assetsByFile = {};
			obj.assetsByChunkName = {};
			obj.assets = Object.keys(compilation.assets).map(asset => {
				const obj = {
					name: asset,
					size: compilation.assets[asset].size(),
					chunks: [],
					chunkNames: [],
					emitted: compilation.assets[asset].emitted
				};
 
				if(showPerformance) {
					obj.isOverSizeLimit = compilation.assets[asset].isOverSizeLimit;
				}
 
				assetsByFile[asset] = obj;
				return obj;
			}).filter(asset => showCachedAssets || asset.emitted);
 
			compilation.chunks.forEach(chunk => {
				chunk.files.forEach(asset => {
					if(assetsByFile[asset]) {
						chunk.ids.forEach(id => {
							assetsByFile[asset].chunks.push(id);
						});
						if(chunk.name) {
							assetsByFile[asset].chunkNames.push(chunk.name);
							if(obj.assetsByChunkName[chunk.name])
								obj.assetsByChunkName[chunk.name] = [].concat(obj.assetsByChunkName[chunk.name]).concat([asset]);
							else
								obj.assetsByChunkName[chunk.name] = asset;
						}
					}
				});
			});
			obj.assets.sort(sortByField(sortAssets));
		}
 
		if(showEntrypoints) {
			obj.entrypoints = {};
			Object.keys(compilation.entrypoints).forEach(name => {
				const ep = compilation.entrypoints[name];
				obj.entrypoints[name] = {
					chunks: ep.chunks.map(c => c.id),
					assets: ep.chunks.reduce((array, c) => array.concat(c.files || []), [])
				};
				if(showPerformance) {
					obj.entrypoints[name].isOverSizeLimit = ep.isOverSizeLimit;
				}
			});
		}
 
		function fnModule(module) {
			const obj = {
				id: module.id,
				identifier: module.identifier(),
				name: module.readableIdentifier(requestShortener),
				index: module.index,
				index2: module.index2,
				size: module.size(),
				cacheable: !!module.cacheable,
				built: !!module.built,
				optional: !!module.optional,
				prefetched: !!module.prefetched,
				chunks: module.chunks.map(chunk => chunk.id),
				assets: Object.keys(module.assets || {}),
				issuer: module.issuer && module.issuer.identifier(),
				issuerId: module.issuer && module.issuer.id,
				issuerName: module.issuer && module.issuer.readableIdentifier(requestShortener),
				profile: module.profile,
				failed: !!module.error,
				errors: module.errors && module.dependenciesErrors && (module.errors.length + module.dependenciesErrors.length),
				warnings: module.errors && module.dependenciesErrors && (module.warnings.length + module.dependenciesWarnings.length)
			};
			if(showReasons) {
				obj.reasons = module.reasons.filter(reason => reason.dependency && reason.module).map(reason => {
					const obj = {
						moduleId: reason.module.id,
						moduleIdentifier: reason.module.identifier(),
						module: reason.module.readableIdentifier(requestShortener),
						moduleName: reason.module.readableIdentifier(requestShortener),
						type: reason.dependency.type,
						userRequest: reason.dependency.userRequest
					};
					const locInfo = formatLocation(reason.dependency.loc);
					if(locInfo) obj.loc = locInfo;
					return obj;
				}).sort((a, b) => a.moduleId - b.moduleId);
			}
			if(showUsedExports) {
				obj.usedExports = module.used ? module.usedExports : false;
			}
			if(showProvidedExports) {
				obj.providedExports = Array.isArray(module.providedExports) ? module.providedExports : null;
			}
			if(showDepth) {
				obj.depth = module.depth;
			}
			if(showSource && module._source) {
				obj.source = module._source.source();
			}
			return obj;
		}
		if(showChunks) {
			obj.chunks = compilation.chunks.map(chunk => {
				const obj = {
					id: chunk.id,
					rendered: chunk.rendered,
					initial: chunk.isInitial(),
					entry: chunk.hasRuntime(),
					recorded: chunk.recorded,
					extraAsync: !!chunk.extraAsync,
					size: chunk.modules.reduce((size, module) => size + module.size(), 0),
					names: chunk.name ? [chunk.name] : [],
					files: chunk.files.slice(),
					hash: chunk.renderedHash,
					parents: chunk.parents.map(c => c.id)
				};
				if(showChunkModules) {
					obj.modules = chunk.modules
						.slice()
						.sort(sortByField("depth"))
						.filter(createModuleFilter())
						.map(fnModule);
					obj.filteredModules = chunk.modules.length - obj.modules.length;
					obj.modules.sort(sortByField(sortModules));
				}
				if(showChunkOrigins) {
					obj.origins = chunk.origins.map(origin => ({
						moduleId: origin.module ? origin.module.id : undefined,
						module: origin.module ? origin.module.identifier() : "",
						moduleIdentifier: origin.module ? origin.module.identifier() : "",
						moduleName: origin.module ? origin.module.readableIdentifier(requestShortener) : "",
						loc: formatLocation(origin.loc),
						name: origin.name,
						reasons: origin.reasons || []
					}));
				}
				return obj;
			});
			obj.chunks.sort(sortByField(sortChunks));
		}
		if(showModules) {
			obj.modules = compilation.modules
				.slice()
				.sort(sortByField("depth"))
				.filter(createModuleFilter())
				.map(fnModule);
			obj.filteredModules = compilation.modules.length - obj.modules.length;
			obj.modules.sort(sortByField(sortModules));
		}
		if(showChildren) {
			obj.children = compilation.children.map((child, idx) => {
				const childOptions = Stats.getChildOptions(options, idx);
				const obj = new Stats(child).toJson(childOptions, forToString);
				delete obj.hash;
				delete obj.version;
				obj.name = child.name;
				return obj;
			});
		}
 
		return obj;
	}
 
	toString(options) {
		if(typeof options === "boolean" || typeof options === "string") {
			options = Stats.presetToOptions(options);
		} else if(!options) {
			options = {};
		}
 
		const useColors = optionOrFallback(options.colors, false);
 
		const obj = this.toJson(options, true);
 
		return Stats.jsonToString(obj, useColors);
	}
 
	static jsonToString(obj, useColors) {
		const buf = [];
 
		const defaultColors = {
			bold: "\u001b[1m",
			yellow: "\u001b[1m\u001b[33m",
			red: "\u001b[1m\u001b[31m",
			green: "\u001b[1m\u001b[32m",
			cyan: "\u001b[1m\u001b[36m",
			magenta: "\u001b[1m\u001b[35m"
		};
 
		const colors = Object.keys(defaultColors).reduce((obj, color) => {
			obj[color] = str => {
				if(useColors) {
					buf.push(
						(useColors === true || useColors[color] === undefined) ?
						defaultColors[color] : useColors[color]
					);
				}
				buf.push(str);
				if(useColors) {
					buf.push("\u001b[39m\u001b[22m");
				}
			};
			return obj;
		}, {
			normal: (str) => buf.push(str)
		});
 
		const coloredTime = (time) => {
			let times = [800, 400, 200, 100];
			if(obj.time) {
				times = [obj.time / 2, obj.time / 4, obj.time / 8, obj.time / 16];
			}
			if(time < times[3])
				colors.normal(`${time}ms`);
			else if(time < times[2])
				colors.bold(`${time}ms`);
			else if(time < times[1])
				colors.green(`${time}ms`);
			else if(time < times[0])
				colors.yellow(`${time}ms`);
			else
				colors.red(`${time}ms`);
		};
 
		const newline = () => buf.push("\n");
 
		const getText = (arr, row, col) => {
			return arr[row][col].value;
		};
 
		const table = (array, align, splitter) => {
			const rows = array.length;
			const cols = array[0].length;
			const colSizes = new Array(cols);
			for(let col = 0; col < cols; col++)
				colSizes[col] = 0;
			for(let row = 0; row < rows; row++) {
				for(let col = 0; col < cols; col++) {
					const value = `${getText(array, row, col)}`;
					if(value.length > colSizes[col]) {
						colSizes[col] = value.length;
					}
				}
			}
			for(let row = 0; row < rows; row++) {
				for(let col = 0; col < cols; col++) {
					const format = array[row][col].color;
					const value = `${getText(array, row, col)}`;
					let l = value.length;
					if(align[col] === "l")
						format(value);
					for(; l < colSizes[col] && col !== cols - 1; l++)
						colors.normal(" ");
					if(align[col] === "r")
						format(value);
					if(col + 1 < cols && colSizes[col] !== 0)
						colors.normal(splitter || "  ");
				}
				newline();
			}
		};
 
		const getAssetColor = (asset, defaultColor) => {
			if(asset.isOverSizeLimit) {
				return colors.yellow;
			}
 
			return defaultColor;
		};
 
		if(obj.hash) {
			colors.normal("Hash: ");
			colors.bold(obj.hash);
			newline();
		}
		if(obj.version) {
			colors.normal("Version: webpack ");
			colors.bold(obj.version);
			newline();
		}
		if(typeof obj.time === "number") {
			colors.normal("Time: ");
			colors.bold(obj.time);
			colors.normal("ms");
			newline();
		}
		if(obj.publicPath) {
			colors.normal("PublicPath: ");
			colors.bold(obj.publicPath);
			newline();
		}
 
		if(obj.assets && obj.assets.length > 0) {
			const t = [
				[{
					value: "Asset",
					color: colors.bold
				}, {
					value: "Size",
					color: colors.bold
				}, {
					value: "Chunks",
					color: colors.bold
				}, {
					value: "",
					color: colors.bold
				}, {
					value: "",
					color: colors.bold
				}, {
					value: "Chunk Names",
					color: colors.bold
				}]
			];
			obj.assets.forEach(asset => {
				t.push([{
					value: asset.name,
					color: getAssetColor(asset, colors.green)
				}, {
					value: SizeFormatHelpers.formatSize(asset.size),
					color: getAssetColor(asset, colors.normal)
				}, {
					value: asset.chunks.join(", "),
					color: colors.bold
				}, {
					value: asset.emitted ? "[emitted]" : "",
					color: colors.green
				}, {
					value: asset.isOverSizeLimit ? "[big]" : "",
					color: getAssetColor(asset, colors.normal)
				}, {
					value: asset.chunkNames.join(", "),
					color: colors.normal
				}]);
			});
			table(t, "rrrlll");
		}
		if(obj.entrypoints) {
			Object.keys(obj.entrypoints).forEach(name => {
				const ep = obj.entrypoints[name];
				colors.normal("Entrypoint ");
				colors.bold(name);
				if(ep.isOverSizeLimit) {
					colors.normal(" ");
					colors.yellow("[big]");
				}
				colors.normal(" =");
				ep.assets.forEach(asset => {
					colors.normal(" ");
					colors.green(asset);
				});
				newline();
			});
		}
		const modulesByIdentifier = {};
		if(obj.modules) {
			obj.modules.forEach(module => {
				modulesByIdentifier[`$${module.identifier}`] = module;
			});
		} else if(obj.chunks) {
			obj.chunks.forEach(chunk => {
				if(chunk.modules) {
					chunk.modules.forEach(module => {
						modulesByIdentifier[`$${module.identifier}`] = module;
					});
				}
			});
		}
 
		const processModuleAttributes = (module) => {
			colors.normal(" ");
			colors.normal(SizeFormatHelpers.formatSize(module.size));
			if(module.chunks) {
				module.chunks.forEach(chunk => {
					colors.normal(" {");
					colors.yellow(chunk);
					colors.normal("}");
				});
			}
			if(typeof module.depth === "number") {
				colors.normal(` [depth ${module.depth}]`);
			}
			if(!module.cacheable) {
				colors.red(" [not cacheable]");
			}
			if(module.optional) {
				colors.yellow(" [optional]");
			}
			if(module.built) {
				colors.green(" [built]");
			}
			if(module.prefetched) {
				colors.magenta(" [prefetched]");
			}
			if(module.failed)
				colors.red(" [failed]");
			if(module.warnings)
				colors.yellow(` [${module.warnings} warning${module.warnings === 1 ? "" : "s"}]`);
			if(module.errors)
				colors.red(` [${module.errors} error${module.errors === 1 ? "" : "s"}]`);
		};
 
		const processModuleContent = (module, prefix) => {
			if(Array.isArray(module.providedExports)) {
				colors.normal(prefix);
				colors.cyan(`[exports: ${module.providedExports.join(", ")}]`);
				newline();
			}
			if(module.usedExports !== undefined) {
				if(module.usedExports !== true) {
					colors.normal(prefix);
					if(module.usedExports === false)
						colors.cyan("[no exports used]");
					else
						colors.cyan(`[only some exports used: ${module.usedExports.join(", ")}]`);
					newline();
				}
			}
			if(module.reasons) {
				module.reasons.forEach(reason => {
					colors.normal(prefix);
					colors.normal(reason.type);
					colors.normal(" ");
					colors.cyan(reason.userRequest);
					colors.normal(" [");
					colors.normal(reason.moduleId);
					colors.normal("] ");
					colors.magenta(reason.module);
					if(reason.loc) {
						colors.normal(" ");
						colors.normal(reason.loc);
					}
					newline();
				});
			}
			if(module.profile) {
				colors.normal(prefix);
				let sum = 0;
				const path = [];
				let current = module;
				while(current.issuer) {
					path.unshift(current = current.issuer);
				}
				path.forEach(module => {
					colors.normal("[");
					colors.normal(module.id);
					colors.normal("] ");
					if(module.profile) {
						const time = (module.profile.factory || 0) + (module.profile.building || 0);
						coloredTime(time);
						sum += time;
						colors.normal(" ");
					}
					colors.normal("->");
				});
				Object.keys(module.profile).forEach(key => {
					colors.normal(` ${key}:`);
					const time = module.profile[key];
					coloredTime(time);
					sum += time;
				});
				colors.normal(" = ");
				coloredTime(sum);
				newline();
			}
		};
 
		if(obj.chunks) {
			obj.chunks.forEach(chunk => {
				colors.normal("chunk ");
				if(chunk.id < 1000) colors.normal(" ");
				if(chunk.id < 100) colors.normal(" ");
				if(chunk.id < 10) colors.normal(" ");
				colors.normal("{");
				colors.yellow(chunk.id);
				colors.normal("} ");
				colors.green(chunk.files.join(", "));
				if(chunk.names && chunk.names.length > 0) {
					colors.normal(" (");
					colors.normal(chunk.names.join(", "));
					colors.normal(")");
				}
				colors.normal(" ");
				colors.normal(SizeFormatHelpers.formatSize(chunk.size));
				chunk.parents.forEach(id => {
					colors.normal(" {");
					colors.yellow(id);
					colors.normal("}");
				});
				if(chunk.entry) {
					colors.yellow(" [entry]");
				} else if(chunk.initial) {
					colors.yellow(" [initial]");
				}
				if(chunk.rendered) {
					colors.green(" [rendered]");
				}
				if(chunk.recorded) {
					colors.green(" [recorded]");
				}
				newline();
				if(chunk.origins) {
					chunk.origins.forEach(origin => {
						colors.normal("    > ");
						if(origin.reasons && origin.reasons.length) {
							colors.yellow(origin.reasons.join(" "));
							colors.normal(" ");
						}
						if(origin.name) {
							colors.normal(origin.name);
							colors.normal(" ");
						}
						if(origin.module) {
							colors.normal("[");
							colors.normal(origin.moduleId);
							colors.normal("] ");
							const module = modulesByIdentifier[`$${origin.module}`];
							if(module) {
								colors.bold(module.name);
								colors.normal(" ");
							}
							if(origin.loc) {
								colors.normal(origin.loc);
							}
						}
						newline();
					});
				}
				if(chunk.modules) {
					chunk.modules.forEach(module => {
						colors.normal(" ");
						if(module.id < 1000) colors.normal(" ");
						if(module.id < 100) colors.normal(" ");
						if(module.id < 10) colors.normal(" ");
						colors.normal("[");
						colors.normal(module.id);
						colors.normal("] ");
						colors.bold(module.name);
						processModuleAttributes(module);
						newline();
						processModuleContent(module, "        ");
					});
					if(chunk.filteredModules > 0) {
						colors.normal(`     + ${chunk.filteredModules} hidden modules`);
						newline();
					}
				}
			});
		}
		if(obj.modules) {
			obj.modules.forEach(module => {
				if(module.id < 1000) colors.normal(" ");
				if(module.id < 100) colors.normal(" ");
				if(module.id < 10) colors.normal(" ");
				colors.normal("[");
				colors.normal(module.id);
				colors.normal("] ");
				colors.bold(module.name || module.identifier);
				processModuleAttributes(module);
				newline();
				processModuleContent(module, "       ");
			});
			if(obj.filteredModules > 0) {
				colors.normal(`    + ${obj.filteredModules} hidden modules`);
				newline();
			}
		}
 
		if(obj._showWarnings && obj.warnings) {
			obj.warnings.forEach(warning => {
				newline();
				colors.yellow(`WARNING in ${warning}`);
				newline();
			});
		}
		if(obj._showErrors && obj.errors) {
			obj.errors.forEach(error => {
				newline();
				colors.red(`ERROR in ${error}`);
				newline();
			});
		}
		if(obj.children) {
			obj.children.forEach(child => {
				const childString = Stats.jsonToString(child, useColors);
				if(childString) {
					if(child.name) {
						colors.normal("Child ");
						colors.bold(child.name);
						colors.normal(":");
					} else {
						colors.normal("Child");
					}
					newline();
					buf.push("    ");
					buf.push(childString.replace(/\n/g, "\n    "));
					newline();
				}
			});
		}
		if(obj.needAdditionalPass) {
			colors.yellow("Compilation needs an additional pass and will compile again.");
		}
 
		while(buf[buf.length - 1] === "\n") buf.pop();
		return buf.join("");
	}
 
	static presetToOptions(name) {
		//Accepted values: none, errors-only, minimal, normal, verbose
		//Any other falsy value will behave as 'none', truthy values as 'normal'
		const pn = (typeof name === "string") && name.toLowerCase() || name;
		if(pn === "none" || !pn) {
			return {
				hash: false,
				version: false,
				timings: false,
				assets: false,
				entrypoints: false,
				chunks: false,
				chunkModules: false,
				modules: false,
				reasons: false,
				depth: false,
				usedExports: false,
				providedExports: false,
				children: false,
				source: false,
				errors: false,
				errorDetails: false,
				warnings: false,
				publicPath: false,
				performance: false
			};
		} else {
			return {
				hash: pn !== "errors-only" && pn !== "minimal",
				version: pn === "verbose",
				timings: pn !== "errors-only" && pn !== "minimal",
				assets: pn === "verbose",
				entrypoints: pn === "verbose",
				chunks: pn !== "errors-only",
				chunkModules: pn === "verbose",
				//warnings: pn !== "errors-only",
				errorDetails: pn !== "errors-only" && pn !== "minimal",
				reasons: pn === "verbose",
				depth: pn === "verbose",
				usedExports: pn === "verbose",
				providedExports: pn === "verbose",
				colors: true,
				performance: true
			};
		}
 
	}
 
	static getChildOptions(options, idx) {
		let innerOptions;
		if(Array.isArray(options.children)) {
			if(idx < options.children.length)
				innerOptions = options.children[idx];
		} else if(typeof options.children === "object" && options.children) {
			innerOptions = options.children;
		}
		if(typeof innerOptions === "boolean" || typeof innerOptions === "string")
			innerOptions = Stats.presetToOptions(innerOptions);
		if(!innerOptions)
			return options;
		const childOptions = Object.assign({}, options);
		delete childOptions.children; // do not inherit children
		return Object.assign(childOptions, innerOptions);
	}
}
 
module.exports = Stats;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Template.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/Template.js

Statements: 7.77% (8 / 103)      Branches: 0% (0 / 58)      Functions: 5.56% (1 / 18)      Lines: 8.99% (8 / 89)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163            1 1   1 1 1   1             1                                                                                                                                                                                                                                                                                   1        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Tapable = require("tapable");
const ConcatSource = require("webpack-sources").ConcatSource;
 
const START_LOWERCASE_ALPHABET_CODE = "a".charCodeAt(0);
const START_UPPERCASE_ALPHABET_CODE = "A".charCodeAt(0);
const DELTA_A_TO_Z = "z".charCodeAt(0) - START_LOWERCASE_ALPHABET_CODE + 1;
 
module.exports = class Template extends Tapable {
	constructor(outputOptions) {
		super();
		this.outputOptions = outputOptions || {};
	}
 
	static getFunctionContent(fn) {
		return fn.toString().replace(/^function\s?\(\)\s?\{\n?|\n?\}$/g, "").replace(/^\t/mg, "");
	}
 
	static toIdentifier(str) {
		if(typeof str !== "string") return "";
		return str.replace(/^[^a-zA-Z$_]/, "_").replace(/[^a-zA-Z0-9$_]/g, "_");
	}
 
	// map number to a single character a-z, A-Z or <_ + number> if number is too big
	static numberToIdentifer(n) {
		// lower case
		if(n < DELTA_A_TO_Z) return String.fromCharCode(START_LOWERCASE_ALPHABET_CODE + n);
 
		// upper case
		n -= DELTA_A_TO_Z;
		if(n < DELTA_A_TO_Z) return String.fromCharCode(START_UPPERCASE_ALPHABET_CODE + n);
 
		// fall back to _ + number
		n -= DELTA_A_TO_Z;
		return "_" + n;
	}
 
	indent(str) {
		if(Array.isArray(str)) {
			return str.map(this.indent.bind(this)).join("\n");
		} else {
			str = str.trimRight();
			if(!str) return "";
			var ind = (str[0] === "\n" ? "" : "\t");
			return ind + str.replace(/\n([^\n])/g, "\n\t$1");
		}
	}
 
	prefix(str, prefix) {
		if(Array.isArray(str)) {
			str = str.join("\n");
		}
		str = str.trim();
		if(!str) return "";
		const ind = (str[0] === "\n" ? "" : prefix);
		return ind + str.replace(/\n([^\n])/g, "\n" + prefix + "$1");
	}
 
	asString(str) {
		if(Array.isArray(str)) {
			return str.join("\n");
		}
		return str;
	}
 
	getModulesArrayBounds(modules) {
		if(!modules.every(moduleIdIsNumber))
			return false;
		var maxId = -Infinity;
		var minId = Infinity;
		modules.forEach(function(module) {
			if(maxId < module.id) maxId = module.id;
			if(minId > module.id) minId = module.id;
		});
		if(minId < 16 + ("" + minId).length) {
			// add minId x ',' instead of 'Array(minId).concat(...)'
			minId = 0;
		}
		var objectOverhead = modules.map(function(module) {
			var idLength = (module.id + "").length;
			return idLength + 2;
		}).reduce(function(a, b) {
			return a + b;
		}, -1);
		var arrayOverhead = minId === 0 ? maxId : 16 + ("" + minId).length + maxId;
		return arrayOverhead < objectOverhead ? [minId, maxId] : false;
	}
 
	renderChunkModules(chunk, moduleTemplate, dependencyTemplates, prefix) {
		if(!prefix) prefix = "";
		var source = new ConcatSource();
		if(chunk.modules.length === 0) {
			source.add("[]");
			return source;
		}
		var removedModules = chunk.removedModules;
		var allModules = chunk.modules.map(function(module) {
			return {
				id: module.id,
				source: moduleTemplate.render(module, dependencyTemplates, chunk)
			};
		});
		if(removedModules && removedModules.length > 0) {
			removedModules.forEach(function(id) {
				allModules.push({
					id: id,
					source: "false"
				});
			});
		}
		var bounds = this.getModulesArrayBounds(chunk.modules);
 
		if(bounds) {
			// Render a spare array
			var minId = bounds[0];
			var maxId = bounds[1];
			if(minId !== 0) source.add("Array(" + minId + ").concat(");
			source.add("[\n");
			var modules = {};
			allModules.forEach(function(module) {
				modules[module.id] = module;
			});
			for(var idx = minId; idx <= maxId; idx++) {
				var module = modules[idx];
				if(idx !== minId) source.add(",\n");
				source.add("/* " + idx + " */");
				if(module) {
					source.add("\n");
					source.add(module.source);
				}
			}
			source.add("\n" + prefix + "]");
			if(minId !== 0) source.add(")");
		} else {
			// Render an object
			source.add("{\n");
			allModules.sort(function(a, b) {
				var aId = a.id + "";
				var bId = b.id + "";
				if(aId < bId) return -1;
				if(aId > bId) return 1;
				return 0;
			}).forEach(function(module, idx) {
				if(idx !== 0) source.add(",\n");
				source.add("\n/***/ " + JSON.stringify(module.id) + ":\n");
				source.add(module.source);
			});
			source.add("\n\n" + prefix + "}");
		}
		return source;
	}
};
 
function moduleIdIsNumber(module) {
	return typeof module.id === "number";
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/TemplatedPathPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/TemplatedPathPlugin.js

Statements: 24.14% (14 / 58)      Branches: 0% (0 / 51)      Functions: 0% (0 / 5)      Lines: 24.56% (14 / 57)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114            1                   1           1 1 1 1 1 1 1 1   1                     1                         1                                                                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Jason Anderson @diurnalist
*/
"use strict";
 
const REGEXP_HASH = /\[hash(?::(\d+))?\]/gi,
	REGEXP_CHUNKHASH = /\[chunkhash(?::(\d+))?\]/gi,
	REGEXP_NAME = /\[name\]/gi,
	REGEXP_ID = /\[id\]/gi,
	REGEXP_FILE = /\[file\]/gi,
	REGEXP_QUERY = /\[query\]/gi,
	REGEXP_FILEBASE = /\[filebase\]/gi;
 
// Using global RegExp for .test is dangerous
// We use a normal RegExp instead of .test
const REGEXP_HASH_FOR_TEST = new RegExp(REGEXP_HASH.source, "i"),
	REGEXP_CHUNKHASH_FOR_TEST = new RegExp(REGEXP_CHUNKHASH.source, "i"),
	REGEXP_NAME_FOR_TEST = new RegExp(REGEXP_NAME.source, "i");
 
// TODO: remove in webpack 3
// Backwards compatibility; expose regexes on Template object
const Template = require("./Template");
Template.REGEXP_HASH = REGEXP_HASH;
Template.REGEXP_CHUNKHASH = REGEXP_CHUNKHASH;
Template.REGEXP_NAME = REGEXP_NAME;
Template.REGEXP_ID = REGEXP_ID;
Template.REGEXP_FILE = REGEXP_FILE;
Template.REGEXP_QUERY = REGEXP_QUERY;
Template.REGEXP_FILEBASE = REGEXP_FILEBASE;
 
const withHashLength = (replacer, handlerFn) => {
	return function(_, hashLength) {
		const length = hashLength && parseInt(hashLength, 10);
		if(length && handlerFn) {
			return handlerFn(length);
		}
		const hash = replacer.apply(this, arguments);
		return length ? hash.slice(0, length) : hash;
	};
};
 
const getReplacer = (value, allowEmpty) => {
	return function(match) {
		// last argument in replacer is the entire input string
		const input = arguments[arguments.length - 1];
		if(value === null || value === undefined) {
			if(!allowEmpty) throw new Error(`Path variable ${match} not implemented in this context: ${input}`);
			return "";
		} else {
			return `${value}`;
		}
	};
};
 
const replacePathVariables = (path, data) => {
	const chunk = data.chunk;
	const chunkId = chunk && chunk.id;
	const chunkName = chunk && (chunk.name || chunk.id);
	const chunkHash = chunk && (chunk.renderedHash || chunk.hash);
	const chunkHashWithLength = chunk && chunk.hashWithLength;
 
	if(data.noChunkHash && REGEXP_CHUNKHASH_FOR_TEST.test(path)) {
		throw new Error(`Cannot use [chunkhash] for chunk in '${path}' (use [hash] instead)`);
	}
 
	return path
		.replace(REGEXP_HASH, withHashLength(getReplacer(data.hash), data.hashWithLength))
		.replace(REGEXP_CHUNKHASH, withHashLength(getReplacer(chunkHash), chunkHashWithLength))
		.replace(REGEXP_ID, getReplacer(chunkId))
		.replace(REGEXP_NAME, getReplacer(chunkName))
		.replace(REGEXP_FILE, getReplacer(data.filename))
		.replace(REGEXP_FILEBASE, getReplacer(data.basename))
		// query is optional, it's OK if it's in a path but there's nothing to replace it with
		.replace(REGEXP_QUERY, getReplacer(data.query, true));
};
 
class TemplatedPathPlugin {
	apply(compiler) {
		compiler.plugin("compilation", compilation => {
			const mainTemplate = compilation.mainTemplate;
 
			mainTemplate.plugin("asset-path", replacePathVariables);
 
			mainTemplate.plugin("global-hash", function(chunk, paths) {
				const outputOptions = this.outputOptions;
				const publicPath = outputOptions.publicPath || "";
				const filename = outputOptions.filename || "";
				const chunkFilename = outputOptions.chunkFilename || outputOptions.filename;
				if(REGEXP_HASH_FOR_TEST.test(publicPath) || REGEXP_CHUNKHASH_FOR_TEST.test(publicPath) || REGEXP_NAME_FOR_TEST.test(publicPath))
					return true;
				if(REGEXP_HASH_FOR_TEST.test(filename))
					return true;
				if(REGEXP_HASH_FOR_TEST.test(chunkFilename))
					return true;
				if(REGEXP_HASH_FOR_TEST.test(paths.join("|")))
					return true;
			});
 
			mainTemplate.plugin("hash-for-chunk", function(hash, chunk) {
				const outputOptions = this.outputOptions;
				const chunkFilename = outputOptions.chunkFilename || outputOptions.filename;
				if(REGEXP_CHUNKHASH_FOR_TEST.test(chunkFilename))
					hash.update(JSON.stringify(chunk.getChunkMaps(true, true).hash));
				if(REGEXP_NAME_FOR_TEST.test(chunkFilename))
					hash.update(JSON.stringify(chunk.getChunkMaps(true, true).name));
			});
		});
	}
}
 
module.exports = TemplatedPathPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/UmdMainTemplatePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/UmdMainTemplatePlugin.js

Statements: 16.44% (12 / 73)      Branches: 0% (0 / 60)      Functions: 0% (0 / 13)      Lines: 18.46% (12 / 65)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178            1 1 1   1       1                                                                       1             1       1               1                               1       1                                                                                                                                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConcatSource = require("webpack-sources").ConcatSource;
const OriginalSource = require("webpack-sources").OriginalSource;
const Template = require("./Template");
 
function accessorToObjectAccess(accessor) {
	return accessor.map(a => `[${JSON.stringify(a)}]`).join("");
}
 
function accessorAccess(base, accessor) {
	accessor = [].concat(accessor);
	return accessor.map((a, idx) => {
		a = base + accessorToObjectAccess(accessor.slice(0, idx + 1));
		if(idx === accessor.length - 1) return a;
		return `${a} = ${a} || {}`;
	}).join(", ");
}
 
class UmdMainTemplatePlugin {
	constructor(name, options) {
		this.name = name;
		this.optionalAmdExternalAsGlobal = options.optionalAmdExternalAsGlobal;
		this.namedDefine = options.namedDefine;
		this.auxiliaryComment = options.auxiliaryComment;
	}
 
	apply(compilation) {
		const mainTemplate = compilation.mainTemplate;
		compilation.templatesPlugin("render-with-entry", function(source, chunk, hash) {
			let externals = chunk.modules.filter(m => m.external);
			const optionalExternals = [];
			let requiredExternals = [];
			if(this.optionalAmdExternalAsGlobal) {
				externals.forEach(m => {
					if(m.optional) {
						optionalExternals.push(m);
					} else {
						requiredExternals.push(m);
					}
				});
				externals = requiredExternals.concat(optionalExternals);
			} else {
				requiredExternals = externals;
			}
 
			function replaceKeys(str) {
				return mainTemplate.applyPluginsWaterfall("asset-path", str, {
					hash,
					chunk
				});
			}
 
			function externalsDepsArray(modules) {
				return `[${replaceKeys(modules.map(m => JSON.stringify(typeof m.request === "object" ? m.request.amd : m.request)).join(", "))}]`;
			}
 
			function externalsRootArray(modules) {
				return replaceKeys(modules.map(m => {
					let request = m.request;
					if(typeof request === "object") request = request.root;
					return `root${accessorToObjectAccess([].concat(request))}`;
				}).join(", "));
			}
 
			function externalsRequireArray(type) {
				return replaceKeys(externals.map(m => {
					let expr;
					let request = m.request;
					if(typeof request === "object") request = request[type];
					if(Array.isArray(request)) {
						expr = `require(${JSON.stringify(request[0])})${accessorToObjectAccess(request.slice(1))}`;
					} else
						expr = `require(${JSON.stringify(request)})`;
					if(m.optional) {
						expr = `(function webpackLoadOptionalExternalModule() { try { return ${expr}; } catch(e) {} }())`;
					}
					return expr;
				}).join(", "));
			}
 
			function externalsArguments(modules) {
				return modules.map(m => Template.toIdentifier(`__WEBPACK_EXTERNAL_MODULE_${m.id}__`)).join(", ");
			}
 
			function libraryName(library) {
				return JSON.stringify(replaceKeys([].concat(library).pop()));
			}
 
			let amdFactory;
			if(optionalExternals.length > 0) {
				const wrapperArguments = externalsArguments(requiredExternals);
				const factoryArguments = requiredExternals.length > 0 ?
					externalsArguments(requiredExternals) + ", " + externalsRootArray(optionalExternals) :
					externalsRootArray(optionalExternals);
				amdFactory = `function webpackLoadOptionalExternalModuleAmd(${wrapperArguments}) {\n` +
					`			return factory(${factoryArguments});\n` +
					"		}";
			} else {
				amdFactory = "factory";
			}
 
			return new ConcatSource(new OriginalSource(
				"(function webpackUniversalModuleDefinition(root, factory) {\n" +
				(this.auxiliaryComment &&
					typeof this.auxiliaryComment === "string" ?
					"   //" + this.auxiliaryComment + "\n" :
					this.auxiliaryComment.commonjs2 ?
					"   //" + this.auxiliaryComment.commonjs2 + "\n" :
					""
				) +
				"	if(typeof exports === 'object' && typeof module === 'object')\n" +
				"		module.exports = factory(" + externalsRequireArray("commonjs2") + ");\n" +
				(this.auxiliaryComment &&
					typeof this.auxiliaryComment === "string" ?
					"   //" + this.auxiliaryComment + "\n" :
					this.auxiliaryComment.amd ?
					"   //" + this.auxiliaryComment.amd + "\n" :
					""
				) +
				"	else if(typeof define === 'function' && define.amd)\n" +
				(requiredExternals.length > 0 ?
					(this.name && this.namedDefine === true ?
						"		define(" + libraryName(this.name) + ", " + externalsDepsArray(requiredExternals) + ", " + amdFactory + ");\n" :
						"		define(" + externalsDepsArray(requiredExternals) + ", " + amdFactory + ");\n"
					) :
					(this.name && this.namedDefine === true ?
						"		define(" + libraryName(this.name) + ", [], " + amdFactory + ");\n" :
						"		define([], " + amdFactory + ");\n"
					)
				) +
				(this.name ?
					(this.auxiliaryComment &&
						typeof this.auxiliaryComment === "string" ?
						"   //" + this.auxiliaryComment + "\n" :
						this.auxiliaryComment.commonjs ?
						"   //" + this.auxiliaryComment.commonjs + "\n" :
						""
					) +
					"	else if(typeof exports === 'object')\n" +
					"		exports[" + libraryName(this.name) + "] = factory(" + externalsRequireArray("commonjs") + ");\n" +
					(this.auxiliaryComment &&
						typeof this.auxiliaryComment === "string" ?
						"   //" + this.auxiliaryComment + "\n" :
						this.auxiliaryComment.root ?
						"   //" + this.auxiliaryComment.root + "\n" :
						""
					) +
					"	else\n" +
					"		" + replaceKeys(accessorAccess("root", this.name)) + " = factory(" + externalsRootArray(externals) + ");\n" :
					"	else {\n" +
					(externals.length > 0 ?
						"		var a = typeof exports === 'object' ? factory(" + externalsRequireArray("commonjs") + ") : factory(" + externalsRootArray(externals) + ");\n" :
						"		var a = factory();\n"
					) +
					"		for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
					"	}\n"
				) +
				"})(this, function(" + externalsArguments(externals) + ") {\nreturn ", "webpack/universalModuleDefinition"), source, ";\n})");
		}.bind(this));
		mainTemplate.plugin("global-hash-paths", function(paths) {
			if(this.name) paths = paths.concat(this.name);
			return paths;
		}.bind(this));
		mainTemplate.plugin("hash", function(hash) {
			hash.update("umd");
			hash.update(`${this.name}`);
		}.bind(this));
	}
}
 
module.exports = UmdMainTemplatePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/UnsupportedFeatureWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/UnsupportedFeatureWarning.js

Statements: 28.57% (2 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 28.57% (2 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23            1                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("./WebpackError");
 
class UnsupportedFeatureWarning extends WebpackError {
	constructor(module, message) {
		super();
 
		this.name = "UnsupportedFeatureWarning";
		this.message = message;
		this.origin = this.module = module;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = UnsupportedFeatureWarning;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/UseStrictPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/UseStrictPlugin.js

Statements: 16.67% (2 / 12)      Branches: 0% (0 / 6)      Functions: 0% (0 / 1)      Lines: 16.67% (2 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36            1                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ConstDependency = require("./dependencies/ConstDependency");
 
class UseStrictPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			params.normalModuleFactory.plugin("parser", (parser) => {
				const parserInstance = parser;
				parser.plugin("program", (ast) => {
					const firstNode = ast.body[0];
					if(firstNode &&
						firstNode.type === "ExpressionStatement" &&
						firstNode.expression.type === "Literal" &&
						firstNode.expression.value === "use strict") {
						// Remove "use strict" expression. It will be added later by the renderer again.
						// This is necessary in order to not break the strict mode when webpack prepends code.
						// @see https://github.com/webpack/webpack/issues/1970
						const dep = new ConstDependency("", firstNode.range);
						dep.loc = firstNode.loc;
						parserInstance.state.current.addDependency(dep);
						parserInstance.state.module.strict = true;
					}
				});
			});
		});
	}
}
 
module.exports = UseStrictPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WarnCaseSensitiveModulesPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WarnCaseSensitiveModulesPlugin.js

Statements: 15.38% (2 / 13)      Branches: 0% (0 / 4)      Functions: 0% (0 / 1)      Lines: 15.38% (2 / 13)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » WarnCaseSensitiveModulesPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33            1                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const CaseSensitiveModulesWarning = require("./CaseSensitiveModulesWarning");
 
class WarnCaseSensitiveModulesPlugin {
	apply(compiler) {
		compiler.plugin("compilation", compilation => {
			compilation.plugin("seal", () => {
				const moduleWithoutCase = Object.create(null);
				compilation.modules.forEach(module => {
					const identifier = module.identifier().toLowerCase();
					if(moduleWithoutCase[identifier]) {
						moduleWithoutCase[identifier].push(module);
					} else {
						moduleWithoutCase[identifier] = [module];
					}
				});
				Object.keys(moduleWithoutCase).forEach(key => {
					if(moduleWithoutCase[key].length > 1)
						compilation.warnings.push(new CaseSensitiveModulesWarning(moduleWithoutCase[key]));
				});
			});
		});
	}
}
 
module.exports = WarnCaseSensitiveModulesPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WatchIgnorePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WatchIgnorePlugin.js

Statements: 4.76% (1 / 21)      Branches: 0% (0 / 4)      Functions: 0% (0 / 4)      Lines: 5.88% (1 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51                                    1                                                                
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class WatchIgnorePlugin {
	constructor(paths) {
		this.paths = paths;
	}
 
	apply(compiler) {
		compiler.plugin("after-environment", () => {
			compiler.watchFileSystem = new IgnoringWatchFileSystem(compiler.watchFileSystem, this.paths);
		});
	}
}
 
module.exports = WatchIgnorePlugin;
 
class IgnoringWatchFileSystem {
	constructor(wfs, paths) {
		this.wfs = wfs;
		this.paths = paths;
	}
 
	watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
		const ignored = path => this.paths.some(p => p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0);
 
		const notIgnored = path => !ignored(path);
 
		const ignoredFiles = files.filter(ignored);
		const ignoredDirs = dirs.filter(ignored);
 
		this.wfs.watch(files.filter(notIgnored), dirs.filter(notIgnored), missing, startTime, options, (err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps) => {
			if(err) return callback(err);
 
			ignoredFiles.forEach(path => {
				fileTimestamps[path] = 1;
			});
 
			ignoredDirs.forEach(path => {
				dirTimestamps[path] = 1;
			});
 
			callback(err, filesModified, dirsModified, missingModified, fileTimestamps, dirTimestamps);
		}, callbackUndelayed);
	}
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackError.js

Statements: 50% (1 / 2)      Branches: 0% (0 / 2)      Functions: 0% (0 / 1)      Lines: 50% (1 / 2)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13            1            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Jarid Margolin @jaridmargolin
*/
"use strict";
 
module.exports = class WebpackError extends Error {
	inspect() {
		return this.stack + (this.details ? `\n${this.details}` : "");
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackOptionsApply.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackOptionsApply.js

Statements: 28.35% (36 / 127)      Branches: 0% (0 / 73)      Functions: 0% (0 / 2)      Lines: 28.57% (36 / 126)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300            1   1 1 1 1 1   1 1   1 1 1 1 1   1 1 1   1 1 1 1 1 1 1 1 1   1 1 1 1 1 1 1 1 1   1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const OptionsApply = require("./OptionsApply");
 
const LoaderTargetPlugin = require("./LoaderTargetPlugin");
const FunctionModulePlugin = require("./FunctionModulePlugin");
const EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin");
const SourceMapDevToolPlugin = require("./SourceMapDevToolPlugin");
const EvalSourceMapDevToolPlugin = require("./EvalSourceMapDevToolPlugin");
 
const EntryOptionPlugin = require("./EntryOptionPlugin");
const RecordIdsPlugin = require("./RecordIdsPlugin");
 
const APIPlugin = require("./APIPlugin");
const ConstPlugin = require("./ConstPlugin");
const RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
const NodeStuffPlugin = require("./NodeStuffPlugin");
const CompatibilityPlugin = require("./CompatibilityPlugin");
 
const TemplatedPathPlugin = require("./TemplatedPathPlugin");
const WarnCaseSensitiveModulesPlugin = require("./WarnCaseSensitiveModulesPlugin");
const UseStrictPlugin = require("./UseStrictPlugin");
 
const LoaderPlugin = require("./dependencies/LoaderPlugin");
const CommonJsPlugin = require("./dependencies/CommonJsPlugin");
const HarmonyModulesPlugin = require("./dependencies/HarmonyModulesPlugin");
const SystemPlugin = require("./dependencies/SystemPlugin");
const ImportPlugin = require("./dependencies/ImportPlugin");
const AMDPlugin = require("./dependencies/AMDPlugin");
const RequireContextPlugin = require("./dependencies/RequireContextPlugin");
const RequireEnsurePlugin = require("./dependencies/RequireEnsurePlugin");
const RequireIncludePlugin = require("./dependencies/RequireIncludePlugin");
 
const EnsureChunkConditionsPlugin = require("./optimize/EnsureChunkConditionsPlugin");
const RemoveParentModulesPlugin = require("./optimize/RemoveParentModulesPlugin");
const RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin");
const MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin");
const FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin");
const OccurrenceOrderPlugin = require("./optimize/OccurrenceOrderPlugin");
const FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin");
const FlagDependencyExportsPlugin = require("./FlagDependencyExportsPlugin");
const SizeLimitsPlugin = require("./performance/SizeLimitsPlugin");
 
const ResolverFactory = require("enhanced-resolve").ResolverFactory;
 
class WebpackOptionsApply extends OptionsApply {
	constructor() {
		super();
	}
 
	process(options, compiler) {
		let ExternalsPlugin;
		compiler.outputPath = options.output.path;
		compiler.recordsInputPath = options.recordsInputPath || options.recordsPath;
		compiler.recordsOutputPath = options.recordsOutputPath || options.recordsPath;
		compiler.name = options.name;
		compiler.dependencies = options.dependencies;
		if(typeof options.target === "string") {
			let JsonpTemplatePlugin;
			let NodeSourcePlugin;
			let NodeTargetPlugin;
			let NodeTemplatePlugin;
 
			switch(options.target) {
				case "web":
					JsonpTemplatePlugin = require("./JsonpTemplatePlugin");
					NodeSourcePlugin = require("./node/NodeSourcePlugin");
					compiler.apply(
						new JsonpTemplatePlugin(options.output),
						new FunctionModulePlugin(options.output),
						new NodeSourcePlugin(options.node),
						new LoaderTargetPlugin("web")
					);
					break;
				case "webworker":
					{
						let WebWorkerTemplatePlugin = require("./webworker/WebWorkerTemplatePlugin");
						NodeSourcePlugin = require("./node/NodeSourcePlugin");
						compiler.apply(
							new WebWorkerTemplatePlugin(),
							new FunctionModulePlugin(options.output),
							new NodeSourcePlugin(options.node),
							new LoaderTargetPlugin("webworker")
						);
						break;
					}
				case "node":
				case "async-node":
					NodeTemplatePlugin = require("./node/NodeTemplatePlugin");
					NodeTargetPlugin = require("./node/NodeTargetPlugin");
					compiler.apply(
						new NodeTemplatePlugin({
							asyncChunkLoading: options.target === "async-node"
						}),
						new FunctionModulePlugin(options.output),
						new NodeTargetPlugin(),
						new LoaderTargetPlugin("node")
					);
					break;
				case "node-webkit":
					JsonpTemplatePlugin = require("./JsonpTemplatePlugin");
					NodeTargetPlugin = require("./node/NodeTargetPlugin");
					ExternalsPlugin = require("./ExternalsPlugin");
					compiler.apply(
						new JsonpTemplatePlugin(options.output),
						new FunctionModulePlugin(options.output),
						new NodeTargetPlugin(),
						new ExternalsPlugin("commonjs", "nw.gui"),
						new LoaderTargetPlugin("node-webkit")
					);
					break;
				case "atom":
				case "electron":
				case "electron-main":
					NodeTemplatePlugin = require("./node/NodeTemplatePlugin");
					NodeTargetPlugin = require("./node/NodeTargetPlugin");
					ExternalsPlugin = require("./ExternalsPlugin");
					compiler.apply(
						new NodeTemplatePlugin({
							asyncChunkLoading: true
						}),
						new FunctionModulePlugin(options.output),
						new NodeTargetPlugin(),
						new ExternalsPlugin("commonjs", [
							"app",
							"auto-updater",
							"browser-window",
							"content-tracing",
							"dialog",
							"electron",
							"global-shortcut",
							"ipc",
							"ipc-main",
							"menu",
							"menu-item",
							"power-monitor",
							"power-save-blocker",
							"protocol",
							"session",
							"web-contents",
							"tray",
							"clipboard",
							"crash-reporter",
							"native-image",
							"screen",
							"shell"
						]),
						new LoaderTargetPlugin(options.target)
					);
					break;
				case "electron-renderer":
					JsonpTemplatePlugin = require("./JsonpTemplatePlugin");
					NodeTargetPlugin = require("./node/NodeTargetPlugin");
					ExternalsPlugin = require("./ExternalsPlugin");
					compiler.apply(
						new JsonpTemplatePlugin(options.output),
						new FunctionModulePlugin(options.output),
						new NodeTargetPlugin(),
						new ExternalsPlugin("commonjs", [
							"desktop-capturer",
							"electron",
							"ipc",
							"ipc-renderer",
							"remote",
							"web-frame",
							"clipboard",
							"crash-reporter",
							"native-image",
							"screen",
							"shell"
						]),
						new LoaderTargetPlugin(options.target)
					);
					break;
				default:
					throw new Error("Unsupported target '" + options.target + "'.");
			}
		} else if(options.target !== false) {
			options.target(compiler);
		} else {
			throw new Error("Unsupported target '" + options.target + "'.");
		}
 
		if(options.output.library || options.output.libraryTarget !== "var") {
			let LibraryTemplatePlugin = require("./LibraryTemplatePlugin");
			compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget, options.output.umdNamedDefine, options.output.auxiliaryComment || ""));
		}
		if(options.externals) {
			ExternalsPlugin = require("./ExternalsPlugin");
			compiler.apply(new ExternalsPlugin(options.output.libraryTarget, options.externals));
		}
		let noSources;
		let legacy;
		let modern;
		let comment;
		if(options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0)) {
			const hidden = options.devtool.indexOf("hidden") >= 0;
			const inline = options.devtool.indexOf("inline") >= 0;
			const evalWrapped = options.devtool.indexOf("eval") >= 0;
			const cheap = options.devtool.indexOf("cheap") >= 0;
			const moduleMaps = options.devtool.indexOf("module") >= 0;
			noSources = options.devtool.indexOf("nosources") >= 0;
			legacy = options.devtool.indexOf("@") >= 0;
			modern = options.devtool.indexOf("#") >= 0;
			comment = legacy && modern ? "\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/" :
				legacy ? "\n/*\n//@ sourceMappingURL=[url]\n*/" :
				modern ? "\n//# sourceMappingURL=[url]" :
				null;
			let Plugin = evalWrapped ? EvalSourceMapDevToolPlugin : SourceMapDevToolPlugin;
			compiler.apply(new Plugin({
				filename: inline ? null : options.output.sourceMapFilename,
				moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate,
				fallbackModuleFilenameTemplate: options.output.devtoolFallbackModuleFilenameTemplate,
				append: hidden ? false : comment,
				module: moduleMaps ? true : cheap ? false : true,
				columns: cheap ? false : true,
				lineToLine: options.output.devtoolLineToLine,
				noSources: noSources,
			}));
		} else if(options.devtool && options.devtool.indexOf("eval") >= 0) {
			legacy = options.devtool.indexOf("@") >= 0;
			modern = options.devtool.indexOf("#") >= 0;
			comment = legacy && modern ? "\n//@ sourceURL=[url]\n//# sourceURL=[url]" :
				legacy ? "\n//@ sourceURL=[url]" :
				modern ? "\n//# sourceURL=[url]" :
				null;
			compiler.apply(new EvalDevToolModulePlugin(comment, options.output.devtoolModuleFilenameTemplate));
		}
 
		compiler.apply(new EntryOptionPlugin());
		compiler.applyPluginsBailResult("entry-option", options.context, options.entry);
 
		compiler.apply(
			new CompatibilityPlugin(),
			new HarmonyModulesPlugin(options.module),
			new AMDPlugin(options.module, options.amd || {}),
			new CommonJsPlugin(options.module),
			new LoaderPlugin(),
			new NodeStuffPlugin(options.node),
			new RequireJsStuffPlugin(),
			new APIPlugin(),
			new ConstPlugin(),
			new UseStrictPlugin(),
			new RequireIncludePlugin(),
			new RequireEnsurePlugin(),
			new RequireContextPlugin(options.resolve.modules, options.resolve.extensions),
			new ImportPlugin(options.module),
			new SystemPlugin(options.module)
		);
 
		compiler.apply(
			new EnsureChunkConditionsPlugin(),
			new RemoveParentModulesPlugin(),
			new RemoveEmptyChunksPlugin(),
			new MergeDuplicateChunksPlugin(),
			new FlagIncludedChunksPlugin(),
			new OccurrenceOrderPlugin(true),
			new FlagDependencyExportsPlugin(),
			new FlagDependencyUsagePlugin()
		);
 
		if(options.performance) {
			compiler.apply(new SizeLimitsPlugin(options.performance));
		}
 
		compiler.apply(new TemplatedPathPlugin());
 
		compiler.apply(new RecordIdsPlugin());
 
		compiler.apply(new WarnCaseSensitiveModulesPlugin());
 
		if(options.cache) {
			let CachePlugin = require("./CachePlugin");
			compiler.apply(new CachePlugin(typeof options.cache === "object" ? options.cache : null));
		}
 
		compiler.applyPlugins("after-plugins", compiler);
		if(!compiler.inputFileSystem) throw new Error("No input filesystem provided");
		compiler.resolvers.normal = ResolverFactory.createResolver(Object.assign({
			fileSystem: compiler.inputFileSystem
		}, options.resolve));
		compiler.resolvers.context = ResolverFactory.createResolver(Object.assign({
			fileSystem: compiler.inputFileSystem,
			resolveToContext: true
		}, options.resolve));
		compiler.resolvers.loader = ResolverFactory.createResolver(Object.assign({
			fileSystem: compiler.inputFileSystem
		}, options.resolveLoader));
		compiler.applyPlugins("after-resolvers", compiler);
		return options;
	}
}
 
module.exports = WebpackOptionsApply;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackOptionsDefaulter.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackOptionsDefaulter.js

Statements: 4.05% (3 / 74)      Branches: 0% (0 / 14)      Functions: 0% (0 / 1)      Lines: 4.05% (3 / 74)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107            1 1                                                                                                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const OptionsDefaulter = require("./OptionsDefaulter");
const Template = require("./Template");
 
class WebpackOptionsDefaulter extends OptionsDefaulter {
	constructor() {
		super();
		this.set("devtool", false);
		this.set("cache", true);
 
		this.set("context", process.cwd());
		this.set("target", "web");
 
		this.set("module.unknownContextRequest", ".");
		this.set("module.unknownContextRegExp", false);
		this.set("module.unknownContextRecursive", true);
		this.set("module.unknownContextCritical", true);
		this.set("module.exprContextRequest", ".");
		this.set("module.exprContextRegExp", false);
		this.set("module.exprContextRecursive", true);
		this.set("module.exprContextCritical", true);
		this.set("module.wrappedContextRegExp", /.*/);
		this.set("module.wrappedContextRecursive", true);
		this.set("module.wrappedContextCritical", false);
		this.set("module.strictExportPresence", false);
 
		this.set("module.unsafeCache", true);
 
		this.set("output", "call", (value, options) => {
			if(typeof value === "string") {
				return {
					filename: value
				};
			} else if(typeof value !== "object") {
				return {};
			} else {
				return value;
			}
		});
		this.set("output.filename", "[name].js");
		this.set("output.chunkFilename", "make", (options) => {
			const filename = options.output.filename;
			return filename.indexOf("[name]") >= 0 ? filename.replace("[name]", "[id]") : "[id]." + filename;
		});
		this.set("output.library", "");
		this.set("output.hotUpdateFunction", "make", (options) => {
			return Template.toIdentifier("webpackHotUpdate" + options.output.library);
		});
		this.set("output.jsonpFunction", "make", (options) => {
			return Template.toIdentifier("webpackJsonp" + options.output.library);
		});
		this.set("output.libraryTarget", "var");
		this.set("output.path", process.cwd());
		this.set("output.sourceMapFilename", "[file].map[query]");
		this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js");
		this.set("output.hotUpdateMainFilename", "[hash].hot-update.json");
		this.set("output.crossOriginLoading", false);
		this.set("output.hashFunction", "md5");
		this.set("output.hashDigest", "hex");
		this.set("output.hashDigestLength", 20);
		this.set("output.devtoolLineToLine", false);
		this.set("output.strictModuleExceptionHandling", false);
 
		this.set("node", {});
		this.set("node.console", false);
		this.set("node.process", true);
		this.set("node.global", true);
		this.set("node.Buffer", true);
		this.set("node.setImmediate", true);
		this.set("node.__filename", "mock");
		this.set("node.__dirname", "mock");
 
		this.set("performance.maxAssetSize", 250000);
		this.set("performance.maxEntrypointSize", 250000);
		this.set("performance.hints", false);
 
		this.set("resolve", {});
		this.set("resolve.unsafeCache", true);
		this.set("resolve.modules", ["node_modules"]);
		this.set("resolve.extensions", [".js", ".json"]);
		this.set("resolve.aliasFields", "make", (options) => {
			if(options.target === "web" || options.target === "webworker")
				return ["browser"];
			else
				return [];
		});
		this.set("resolve.mainFields", "make", (options) => {
			if(options.target === "web" || options.target === "webworker")
				return ["browser", "module", "main"];
			else
				return ["module", "main"];
		});
		this.set("resolveLoader", {});
		this.set("resolveLoader.unsafeCache", true);
		this.set("resolveLoader.mainFields", ["loader", "main"]);
		this.set("resolveLoader.extensions", [".js", ".json"]);
	}
}
 
module.exports = WebpackOptionsDefaulter;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackOptionsValidationError.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/WebpackOptionsValidationError.js

Statements: 4.84% (6 / 124)      Branches: 0% (0 / 99)      Functions: 0% (0 / 3)      Lines: 5.26% (6 / 114)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/ » WebpackOptionsValidationError.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198            1 1   1                                 1                             1                                                                                                                                                                                                                                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Gajus Kuizinas @gajus
*/
"use strict";
 
const WebpackError = require("./WebpackError");
const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");
 
const getSchemaPart = (path, parents, additionalPath) => {
	parents = parents || 0;
	path = path.split("/");
	path = path.slice(0, path.length - parents);
	if(additionalPath) {
		additionalPath = additionalPath.split("/");
		path = path.concat(additionalPath);
	}
	let schemaPart = webpackOptionsSchema;
	for(let i = 1; i < path.length; i++) {
		const inner = schemaPart[path[i]];
		if(inner)
			schemaPart = inner;
	}
	return schemaPart;
};
 
const getSchemaPartText = (schemaPart, additionalPath) => {
	if(additionalPath) {
		for(let i = 0; i < additionalPath.length; i++) {
			const inner = schemaPart[additionalPath[i]];
			if(inner)
				schemaPart = inner;
		}
	}
	while(schemaPart.$ref) schemaPart = getSchemaPart(schemaPart.$ref);
	let schemaText = WebpackOptionsValidationError.formatSchema(schemaPart);
	if(schemaPart.description)
		schemaText += `\n${schemaPart.description}`;
	return schemaText;
};
 
const indent = (str, prefix, firstLine) => {
	if(firstLine) {
		return prefix + str.replace(/\n(?!$)/g, "\n" + prefix);
	} else {
		return str.replace(/\n(?!$)/g, `\n${prefix}`);
	}
};
 
class WebpackOptionsValidationError extends WebpackError {
	constructor(validationErrors) {
		super();
 
		this.name = "WebpackOptionsValidationError";
		this.message = "Invalid configuration object. " +
			"Webpack has been initialised using a configuration object that does not match the API schema.\n" +
			validationErrors.map(err => " - " + indent(WebpackOptionsValidationError.formatValidationError(err), "   ", false)).join("\n");
		this.validationErrors = validationErrors;
 
		Error.captureStackTrace(this, this.constructor);
	}
 
	static formatSchema(schema, prevSchemas) {
		prevSchemas = prevSchemas || [];
 
		const formatInnerSchema = (innerSchema, addSelf) => {
			if(!addSelf) return WebpackOptionsValidationError.formatSchema(innerSchema, prevSchemas);
			if(prevSchemas.indexOf(innerSchema) >= 0) return "(recursive)";
			return WebpackOptionsValidationError.formatSchema(innerSchema, prevSchemas.concat(schema));
		};
 
		if(schema.type === "string") {
			if(schema.minLength === 1)
				return "non-empty string";
			else if(schema.minLength > 1)
				return `string (min length ${schema.minLength})`;
			return "string";
		} else if(schema.type === "boolean") {
			return "boolean";
		} else if(schema.type === "number") {
			return "number";
		} else if(schema.type === "object") {
			if(schema.properties) {
				const required = schema.required || [];
				return `object { ${Object.keys(schema.properties).map(property => {
					if(required.indexOf(property) < 0) return property + "?";
					return property;
				}).concat(schema.additionalProperties ? ["..."] : []).join(", ")} }`;
			}
			if(schema.additionalProperties) {
				return `object { <key>: ${formatInnerSchema(schema.additionalProperties)} }`;
			}
			return "object";
		} else if(schema.type === "array") {
			return `[${formatInnerSchema(schema.items)}]`;
		}
 
		switch(schema.instanceof) {
			case "Function":
				return "function";
			case "RegExp":
				return "RegExp";
		}
		if(schema.$ref) return formatInnerSchema(getSchemaPart(schema.$ref), true);
		if(schema.allOf) return schema.allOf.map(formatInnerSchema).join(" & ");
		if(schema.oneOf) return schema.oneOf.map(formatInnerSchema).join(" | ");
		if(schema.anyOf) return schema.anyOf.map(formatInnerSchema).join(" | ");
		if(schema.enum) return schema.enum.map(item => JSON.stringify(item)).join(" | ");
		return JSON.stringify(schema, 0, 2);
	}
 
	static formatValidationError(err) {
		const dataPath = `configuration${err.dataPath}`;
		if(err.keyword === "additionalProperties") {
			const baseMessage = `${dataPath} has an unknown property '${err.params.additionalProperty}'. These properties are valid:\n${getSchemaPartText(err.parentSchema)}`;
			if(!err.dataPath) {
				switch(err.params.additionalProperty) {
					case "debug":
						return `${baseMessage}\n` +
							"The 'debug' property was removed in webpack 2.\n" +
							"Loaders should be updated to allow passing this option via loader options in module.rules.\n" +
							"Until loaders are updated one can use the LoaderOptionsPlugin to switch loaders into debug mode:\n" +
							"plugins: [\n" +
							"  new webpack.LoaderOptionsPlugin({\n" +
							"    debug: true\n" +
							"  })\n" +
							"]";
				}
				return baseMessage + "\n" +
					"For typos: please correct them.\n" +
					"For loader options: webpack 2 no longer allows custom properties in configuration.\n" +
					"  Loaders should be updated to allow passing options via loader options in module.rules.\n" +
					"  Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader:\n" +
					"  plugins: [\n" +
					"    new webpack.LoaderOptionsPlugin({\n" +
					"      // test: /\\.xxx$/, // may apply this only for some modules\n" +
					"      options: {\n" +
					`        ${err.params.additionalProperty}: ...\n` +
					"      }\n" +
					"    })\n" +
					"  ]";
			}
			return baseMessage;
		} else if(err.keyword === "oneOf" || err.keyword === "anyOf") {
			if(err.children && err.children.length > 0) {
				return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}\n` +
					`Details:\n${err.children.map(err => " * " + indent(WebpackOptionsValidationError.formatValidationError(err), "   ", false)).join("\n")}`;
			}
			return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
 
		} else if(err.keyword === "enum") {
			if(err.parentSchema && err.parentSchema.enum && err.parentSchema.enum.length === 1) {
				return `${dataPath} should be ${getSchemaPartText(err.parentSchema)}`;
			}
			return `${dataPath} should be one of these:\n${getSchemaPartText(err.parentSchema)}`;
		} else if(err.keyword === "allOf") {
			return `${dataPath} should be:\n${getSchemaPartText(err.parentSchema)}`;
		} else if(err.keyword === "type") {
			switch(err.params.type) {
				case "object":
					return `${dataPath} should be an object.`;
				case "string":
					return `${dataPath} should be a string.`;
				case "boolean":
					return `${dataPath} should be a boolean.`;
				case "number":
					return `${dataPath} should be a number.`;
				case "array":
					return `${dataPath} should be an array:\n${getSchemaPartText(err.parentSchema)}`;
			}
			return `${dataPath} should be ${err.params.type}:\n${getSchemaPartText(err.parentSchema)}`;
		} else if(err.keyword === "instanceof") {
			return `${dataPath} should be an instance of ${getSchemaPartText(err.parentSchema)}.`;
		} else if(err.keyword === "required") {
			const missingProperty = err.params.missingProperty.replace(/^\./, "");
			return `${dataPath} misses the property '${missingProperty}'.\n${getSchemaPartText(err.parentSchema, ["properties", missingProperty])}`;
		} else if(err.keyword === "minLength" || err.keyword === "minItems") {
			if(err.params.limit === 1)
				return `${dataPath} should not be empty.`;
			else
				return `${dataPath} ${err.message}`;
		} else if(err.keyword === "absolutePath") {
			const baseMessage = `${dataPath}: ${err.message}`;
			if(dataPath === "configuration.output.filename") {
				return `${baseMessage}\n` +
					"Please use output.path to specify absolute path and output.filename for the file name.";
			}
			return baseMessage;
		} else {
			// eslint-disable-line no-fallthrough
			return `${dataPath} ${err.message} (${JSON.stringify(err, 0, 2)}).\n${getSchemaPartText(err.parentSchema)}`;
		}
	}
}
 
module.exports = WebpackOptionsValidationError;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/compareLocations.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/compareLocations.js

Statements: 3.13% (1 / 32)      Branches: 0% (0 / 32)      Functions: 0% (0 / 1)      Lines: 4.17% (1 / 24)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38          1                                                                
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
module.exports = function compareLocations(a, b) {
	if(typeof a === "string") {
		if(typeof b === "string") {
			if(a < b) return -1;
			if(a > b) return 1;
			return 0;
		} else if(typeof b === "object") {
			return 1;
		} else {
			return 0;
		}
	} else if(typeof a === "object") {
		if(typeof b === "string") {
			return -1;
		} else if(typeof b === "object") {
			if(a.start && b.start) {
				const ap = a.start;
				const bp = b.start;
				if(ap.line < bp.line) return -1;
				if(ap.line > bp.line) return 1;
				if(ap.column < bp.column) return -1;
				if(ap.column > bp.column) return 1;
			}
			if(a.index < b.index) return -1;
			if(a.index > b.index) return 1;
			return 0;
		} else {
			return 0;
		}
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/formatLocation.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/formatLocation.js

Statements: 7.41% (2 / 27)      Branches: 0% (0 / 36)      Functions: 0% (0 / 2)      Lines: 7.41% (2 / 27)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39        1                                 1                                  
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
module.exports = function formatLocation(loc) {
	if(typeof loc === "string")
		return loc;
	if(typeof loc === "number")
		return loc + "";
	if(loc && typeof loc === "object") {
		if(loc.start && loc.end) {
			if(typeof loc.start.line === "number" && typeof loc.end.line === "number" && typeof loc.end.column === "number" && loc.start.line === loc.end.line)
				return formatPosition(loc.start) + "-" + loc.end.column;
			return formatPosition(loc.start) + "-" + formatPosition(loc.end);
		}
		if(loc.start)
			return formatPosition(loc.start);
		return formatPosition(loc);
	}
	return "";
 
	function formatPosition(pos) {
		if(typeof pos === "string")
			return pos;
		if(typeof pos === "number")
			return pos + "";
		if(pos && typeof pos === "object") {
			if(typeof pos.line === "number" && typeof pos.column === "number")
				return pos.line + ":" + pos.column;
			if(typeof pos.line === "number")
				return pos.line + ":?";
			if(typeof pos.index === "number")
				return "+" + pos.index;
		}
		return "";
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/removeAndDo.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/removeAndDo.js

Statements: 14.29% (1 / 7)      Branches: 0% (0 / 2)      Functions: 0% (0 / 1)      Lines: 14.29% (1 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17            1                    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
module.exports = function removeAndDo(collection, thing, action) {
	const idx = this[collection].indexOf(thing);
	const hasThingInCollection = idx >= 0;
	if(hasThingInCollection) {
		this[collection].splice(idx, 1);
		thing[action](this);
	}
	return hasThingInCollection;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/validateSchema.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/validateSchema.js

Statements: 21.05% (8 / 38)      Branches: 0% (0 / 12)      Functions: 0% (0 / 4)      Lines: 21.62% (8 / 37)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68            1 1         1 1   1                                     1           1                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Gajus Kuizinas @gajus
*/
"use strict";
 
const Ajv = require("ajv");
const ajv = new Ajv({
	errorDataPath: "configuration",
	allErrors: true,
	verbose: true
});
require("ajv-keywords")(ajv, ["instanceof"]);
require("../schemas/ajv.absolutePath")(ajv);
 
function validateSchema(schema, options) {
	if(Array.isArray(options)) {
		const errors = options.map((options) => validateObject(schema, options));
		errors.forEach((list, idx) => {
			list.forEach(function applyPrefix(err) {
				err.dataPath = `[${idx}]${err.dataPath}`;
				if(err.children) {
					err.children.forEach(applyPrefix);
				}
			});
		});
		return errors.reduce((arr, items) => {
			return arr.concat(items);
		}, []);
	} else {
		return validateObject(schema, options);
	}
}
 
function validateObject(schema, options) {
	const validate = ajv.compile(schema);
	const valid = validate(options);
	return valid ? [] : filterErrors(validate.errors);
}
 
function filterErrors(errors) {
	let newErrors = [];
	errors.forEach((err) => {
		const dataPath = err.dataPath;
		let children = [];
		newErrors = newErrors.filter((oldError) => {
			if(oldError.dataPath.includes(dataPath)) {
				if(oldError.children) {
					children = children.concat(oldError.children.slice(0));
				}
				oldError.children = undefined;
				children.push(oldError);
				return false;
			}
			return true;
		});
		if(children.length) {
			err.children = children;
		}
		newErrors.push(err);
	});
 
	return newErrors;
}
 
module.exports = validateSchema;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/webpack.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/webpack.js

Statements: 46.3% (25 / 54)      Branches: 0% (0 / 25)      Functions: 66.67% (2 / 3)      Lines: 50% (25 / 50)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122            1 1 1 1 1 1 1 1   1                                                                   1   1 1 1 1 1 1 1 1   1 3 43       196           1                                                                       1                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Compiler = require("./Compiler");
const MultiCompiler = require("./MultiCompiler");
const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
const WebpackOptionsApply = require("./WebpackOptionsApply");
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
const validateSchema = require("./validateSchema");
const WebpackOptionsValidationError = require("./WebpackOptionsValidationError");
const webpackOptionsSchema = require("../schemas/webpackOptionsSchema.json");
 
function webpack(options, callback) {
	const webpackOptionsValidationErrors = validateSchema(webpackOptionsSchema, options);
	if(webpackOptionsValidationErrors.length) {
		throw new WebpackOptionsValidationError(webpackOptionsValidationErrors);
	}
	let compiler;
	if(Array.isArray(options)) {
		compiler = new MultiCompiler(options.map(options => webpack(options)));
	} else if(typeof options === "object") {
		new WebpackOptionsDefaulter().process(options);
 
		compiler = new Compiler();
		compiler.context = options.context;
		compiler.options = options;
		new NodeEnvironmentPlugin().apply(compiler);
		if(options.plugins && Array.isArray(options.plugins)) {
			compiler.apply.apply(compiler, options.plugins);
		}
		compiler.applyPlugins("environment");
		compiler.applyPlugins("after-environment");
		compiler.options = new WebpackOptionsApply().process(options, compiler);
	} else {
		throw new Error("Invalid argument: options");
	}
	if(callback) {
		if(typeof callback !== "function") throw new Error("Invalid argument: callback");
		if(options.watch === true || (Array.isArray(options) && options.some(o => o.watch))) {
			const watchOptions = Array.isArray(options) ? options.map(o => o.watchOptions || {}) : (options.watchOptions || {});
			return compiler.watch(watchOptions, callback);
		}
		compiler.run(callback);
	}
	return compiler;
}
exports = module.exports = webpack;
 
webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;
webpack.WebpackOptionsApply = WebpackOptionsApply;
webpack.Compiler = Compiler;
webpack.MultiCompiler = MultiCompiler;
webpack.NodeEnvironmentPlugin = NodeEnvironmentPlugin;
webpack.validate = validateSchema.bind(this, webpackOptionsSchema);
webpack.validateSchema = validateSchema;
webpack.WebpackOptionsValidationError = WebpackOptionsValidationError;
 
function exportPlugins(exports, path, plugins) {
	plugins.forEach(name => {
		Object.defineProperty(exports, name, {
			configurable: false,
			enumerable: true,
			get() {
				return require(`${path}/${name}`);
			}
		});
	});
}
 
exportPlugins(exports, ".", [
	"DefinePlugin",
	"NormalModuleReplacementPlugin",
	"ContextReplacementPlugin",
	"IgnorePlugin",
	"WatchIgnorePlugin",
	"BannerPlugin",
	"PrefetchPlugin",
	"AutomaticPrefetchPlugin",
	"ProvidePlugin",
	"HotModuleReplacementPlugin",
	"SourceMapDevToolPlugin",
	"EvalSourceMapDevToolPlugin",
	"EvalDevToolModulePlugin",
	"CachePlugin",
	"ExtendedAPIPlugin",
	"ExternalsPlugin",
	"JsonpTemplatePlugin",
	"LibraryTemplatePlugin",
	"LoaderTargetPlugin",
	"MemoryOutputFileSystem",
	"ProgressPlugin",
	"SetVarMainTemplatePlugin",
	"UmdMainTemplatePlugin",
	"NoErrorsPlugin",
	"NoEmitOnErrorsPlugin",
	"NewWatchingPlugin",
	"EnvironmentPlugin",
	"DllPlugin",
	"DllReferencePlugin",
	"LoaderOptionsPlugin",
	"NamedModulesPlugin",
	"NamedChunksPlugin",
	"HashedModuleIdsPlugin",
	"ModuleFilenameHelpers"
]);
exportPlugins(exports.optimize = {}, "./optimize", [
	"AggressiveMergingPlugin",
	"AggressiveSplittingPlugin",
	"CommonsChunkPlugin",
	"ChunkModuleIdRangePlugin",
	"DedupePlugin",
	"LimitChunkCountPlugin",
	"MinChunkSizePlugin",
	"OccurrenceOrderPlugin",
	"UglifyJsPlugin"
]);
exportPlugins(exports.dependencies = {}, "./dependencies", []);
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/webpack.web.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/webpack.web.js

Statements: 55.56% (10 / 18)      Branches: 0% (0 / 2)      Functions: 0% (0 / 1)      Lines: 55.56% (10 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31            1 1 1 1   1                       1   1 1 1 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Compiler = require("./Compiler");
const WebEnvironmentPlugin = require("./web/WebEnvironmentPlugin");
const WebpackOptionsApply = require("./WebpackOptionsApply");
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
 
function webpack(options, callback) {
	new WebpackOptionsDefaulter().process(options);
 
	const compiler = new Compiler();
	compiler.options = options;
	compiler.options = new WebpackOptionsApply().process(options, compiler);
	new WebEnvironmentPlugin(options.inputFileSystem, options.outputFileSystem).apply(compiler);
	if(callback) {
		compiler.run(callback);
	}
	return compiler;
}
module.exports = webpack;
 
webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;
webpack.WebpackOptionsApply = WebpackOptionsApply;
webpack.Compiler = Compiler;
webpack.WebEnvironmentPlugin = WebEnvironmentPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/

Statements: 15.61% (306 / 1960)      Branches: 0% (0 / 904)      Functions: 0% (0 / 216)      Lines: 16.22% (306 / 1886)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/
File Statements Branches Functions Lines
AMDDefineDependency.js 6.82% (3 / 44) 0% (0 / 25) 0% (0 / 7) 6.98% (3 / 43)
AMDDefineDependencyParserPlugin.js 5.62% (10 / 178) 0% (0 / 122) 0% (0 / 3) 6.06% (10 / 165)
AMDPlugin.js 22.06% (15 / 68) 0% (0 / 4) 0% (0 / 3) 22.06% (15 / 68)
AMDRequireArrayDependency.js 17.39% (4 / 23) 0% (0 / 6) 0% (0 / 6) 17.39% (4 / 23)
AMDRequireContextDependency.js 40% (4 / 10) 0% (0 / 2) 0% (0 / 3) 40% (4 / 10)
AMDRequireDependenciesBlock.js 13.64% (3 / 22) 0% (0 / 13) 0% (0 / 1) 13.64% (3 / 22)
AMDRequireDependenciesBlockParserPlugin.js 9.92% (12 / 121) 0% (0 / 60) 0% (0 / 3) 10.08% (12 / 119)
AMDRequireDependency.js 10.26% (4 / 39) 0% (0 / 23) 0% (0 / 2) 10.26% (4 / 39)
AMDRequireItemDependency.js 57.14% (4 / 7) 100% (0 / 0) 0% (0 / 2) 57.14% (4 / 7)
CommonJsPlugin.js 22.22% (12 / 54) 0% (0 / 4) 0% (0 / 2) 23.08% (12 / 52)
CommonJsRequireContextDependency.js 41.67% (5 / 12) 0% (0 / 2) 0% (0 / 3) 41.67% (5 / 12)
CommonJsRequireDependency.js 57.14% (4 / 7) 100% (0 / 0) 0% (0 / 2) 57.14% (4 / 7)
CommonJsRequireDependencyParserPlugin.js 12.7% (8 / 63) 0% (0 / 20) 0% (0 / 3) 13.11% (8 / 61)
ConstDependency.js 25% (3 / 12) 0% (0 / 2) 0% (0 / 3) 25% (3 / 12)
ContextDependency.js 18.18% (2 / 11) 0% (0 / 6) 0% (0 / 2) 18.18% (2 / 11)
ContextDependencyHelpers.js 6.25% (3 / 48) 0% (0 / 39) 0% (0 / 2) 6.25% (3 / 48)
ContextDependencyTemplateAsId.js 7.69% (1 / 13) 0% (0 / 13) 0% (0 / 1) 7.69% (1 / 13)
ContextDependencyTemplateAsRequireCall.js 6.67% (1 / 15) 0% (0 / 18) 0% (0 / 1) 6.67% (1 / 15)
ContextElementDependency.js 33.33% (2 / 6) 0% (0 / 2) 0% (0 / 2) 33.33% (2 / 6)
CriticalDependencyWarning.js 33.33% (2 / 6) 100% (0 / 0) 0% (0 / 1) 33.33% (2 / 6)
DelegatedSourceDependency.js 50% (2 / 4) 100% (0 / 0) 0% (0 / 2) 50% (2 / 4)
DepBlockHelpers.js 21.05% (4 / 19) 0% (0 / 18) 0% (0 / 5) 22.22% (4 / 18)
DllEntryDependency.js 33.33% (2 / 6) 100% (0 / 0) 0% (0 / 2) 33.33% (2 / 6)
HarmonyAcceptDependency.js 25% (4 / 16) 0% (0 / 2) 0% (0 / 3) 25% (4 / 16)
HarmonyAcceptImportDependency.js 60% (3 / 5) 100% (0 / 0) 0% (0 / 3) 60% (3 / 5)
HarmonyCompatibilityDependency.js 27.27% (3 / 11) 0% (0 / 6) 0% (0 / 3) 27.27% (3 / 11)
HarmonyDetectionParserPlugin.js 14.29% (4 / 28) 0% (0 / 12) 0% (0 / 3) 14.29% (4 / 28)
HarmonyExportDependencyParserPlugin.js 15.52% (9 / 58) 0% (0 / 22) 0% (0 / 3) 16.67% (9 / 54)
HarmonyExportExpressionDependency.js 14.29% (3 / 21) 0% (0 / 6) 0% (0 / 6) 14.29% (3 / 21)
HarmonyExportHeaderDependency.js 30% (3 / 10) 0% (0 / 2) 0% (0 / 3) 30% (3 / 10)
HarmonyExportImportedSpecifierDependency.js 2.94% (4 / 136) 0% (0 / 108) 0% (0 / 16) 3.13% (4 / 128)
HarmonyExportSpecifierDependency.js 15.38% (4 / 26) 0% (0 / 14) 0% (0 / 7) 15.38% (4 / 26)
HarmonyImportDependency.js 17.65% (6 / 34) 0% (0 / 19) 0% (0 / 7) 18.18% (6 / 33)
HarmonyImportDependencyParserPlugin.js 7.79% (6 / 77) 0% (0 / 12) 0% (0 / 2) 7.89% (6 / 76)
HarmonyImportSpecifierDependency.js 4.84% (3 / 62) 0% (0 / 57) 0% (0 / 11) 4.92% (3 / 61)
HarmonyModulesHelpers.js 2% (1 / 50) 0% (0 / 48) 0% (0 / 6) 2.27% (1 / 44)
HarmonyModulesPlugin.js 35.9% (14 / 39) 0% (0 / 4) 0% (0 / 2) 35.9% (14 / 39)
ImportContextDependency.js 35.71% (5 / 14) 0% (0 / 2) 0% (0 / 3) 35.71% (5 / 14)
ImportDependenciesBlock.js 37.5% (3 / 8) 100% (0 / 0) 0% (0 / 1) 37.5% (3 / 8)
ImportDependency.js 21.74% (5 / 23) 0% (0 / 8) 0% (0 / 5) 21.74% (5 / 23)
ImportParserPlugin.js 14.29% (4 / 28) 0% (0 / 12) 0% (0 / 2) 14.81% (4 / 27)
ImportPlugin.js 23.53% (4 / 17) 0% (0 / 4) 0% (0 / 2) 23.53% (4 / 17)
LoaderDependency.js 50% (2 / 4) 100% (0 / 0) 0% (0 / 2) 50% (2 / 4)
LoaderPlugin.js 7.5% (3 / 40) 0% (0 / 18) 0% (0 / 3) 9.38% (3 / 32)
LocalModule.js 14.29% (1 / 7) 100% (0 / 0) 0% (0 / 3) 14.29% (1 / 7)
LocalModuleDependency.js 30% (3 / 10) 0% (0 / 2) 0% (0 / 2) 33.33% (3 / 9)
LocalModulesHelpers.js 20% (6 / 30) 0% (0 / 14) 100% (0 / 0) 24% (6 / 25)
ModuleDependency.js 25% (2 / 8) 0% (0 / 2) 0% (0 / 2) 25% (2 / 8)
ModuleDependencyTemplateAsId.js 11.11% (1 / 9) 0% (0 / 6) 0% (0 / 1) 12.5% (1 / 8)
ModuleDependencyTemplateAsRequireId.js 11.11% (1 / 9) 0% (0 / 6) 0% (0 / 1) 12.5% (1 / 8)
ModuleHotAcceptDependency.js 50% (4 / 8) 100% (0 / 0) 0% (0 / 2) 50% (4 / 8)
ModuleHotDeclineDependency.js 50% (4 / 8) 100% (0 / 0) 0% (0 / 2) 50% (4 / 8)
MultiEntryDependency.js 33.33% (2 / 6) 100% (0 / 0) 0% (0 / 2) 33.33% (2 / 6)
NullDependency.js 60% (3 / 5) 100% (0 / 0) 0% (0 / 4) 60% (3 / 5)
PrefetchDependency.js 50% (2 / 4) 100% (0 / 0) 0% (0 / 2) 50% (2 / 4)
RequireContextDependency.js 57.14% (4 / 7) 100% (0 / 0) 0% (0 / 2) 57.14% (4 / 7)
RequireContextDependencyParserPlugin.js 9.09% (2 / 22) 0% (0 / 9) 0% (0 / 1) 10.53% (2 / 19)
RequireContextPlugin.js 9.3% (4 / 43) 0% (0 / 16) 0% (0 / 2) 9.76% (4 / 41)
RequireEnsureDependenciesBlock.js 18.75% (3 / 16) 0% (0 / 10) 0% (0 / 1) 18.75% (3 / 16)
RequireEnsureDependenciesBlockParserPlugin.js 6.67% (4 / 60) 0% (0 / 37) 0% (0 / 1) 6.9% (4 / 58)
RequireEnsureDependency.js 22.22% (4 / 18) 0% (0 / 5) 0% (0 / 3) 22.22% (4 / 18)
RequireEnsureItemDependency.js 66.67% (4 / 6) 100% (0 / 0) 0% (0 / 2) 66.67% (4 / 6)
RequireEnsurePlugin.js 33.33% (6 / 18) 0% (0 / 4) 0% (0 / 1) 33.33% (6 / 18)
RequireHeaderDependency.js 33.33% (3 / 9) 0% (0 / 2) 0% (0 / 3) 37.5% (3 / 8)
RequireIncludeDependency.js 27.27% (3 / 11) 0% (0 / 4) 0% (0 / 4) 27.27% (3 / 11)
RequireIncludeDependencyParserPlugin.js 16.67% (2 / 12) 0% (0 / 4) 0% (0 / 1) 20% (2 / 10)
RequireIncludePlugin.js 28.57% (4 / 14) 0% (0 / 4) 0% (0 / 1) 28.57% (4 / 14)
RequireResolveContextDependency.js 41.67% (5 / 12) 0% (0 / 2) 0% (0 / 3) 41.67% (5 / 12)
RequireResolveDependency.js 57.14% (4 / 7) 100% (0 / 0) 0% (0 / 2) 57.14% (4 / 7)
RequireResolveDependencyParserPlugin.js 10.42% (5 / 48) 0% (0 / 12) 0% (0 / 2) 10.87% (5 / 46)
RequireResolveHeaderDependency.js 33.33% (3 / 9) 0% (0 / 2) 0% (0 / 3) 37.5% (3 / 8)
SingleEntryDependency.js 50% (2 / 4) 100% (0 / 0) 0% (0 / 2) 50% (2 / 4)
SystemPlugin.js 15% (3 / 20) 0% (0 / 4) 0% (0 / 4) 15% (3 / 20)
UnsupportedDependency.js 50% (4 / 8) 100% (0 / 0) 0% (0 / 2) 50% (4 / 8)
WebpackMissingModule.js 40% (4 / 10) 100% (0 / 0) 100% (0 / 0) 50% (4 / 8)
getFunctionExpression.js 14.29% (1 / 7) 0% (0 / 24) 0% (0 / 1) 14.29% (1 / 7)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDDefineDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDDefineDependency.js

Statements: 6.82% (3 / 44)      Branches: 0% (0 / 25)      Functions: 0% (0 / 7)      Lines: 6.98% (3 / 43)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144          1                                 1                                                                                                                                                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class AMDDefineDependency extends NullDependency {
	constructor(range, arrayRange, functionRange, objectRange, namedModule) {
		super();
		this.range = range;
		this.arrayRange = arrayRange;
		this.functionRange = functionRange;
		this.objectRange = objectRange;
		this.namedModule = namedModule;
	}
 
	get type() {
		return "amd define";
	}
}
 
AMDDefineDependency.Template = class AMDDefineDependencyTemplate {
	get definitions() {
		return {
			f: [
				"var __WEBPACK_AMD_DEFINE_RESULT__;",
				`!(__WEBPACK_AMD_DEFINE_RESULT__ = #.call(exports, __webpack_require__, exports, module),
				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))`
			],
			o: [
				"",
				"!(module.exports = #)"
			],
			of: [
				"var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;",
				`!(__WEBPACK_AMD_DEFINE_FACTORY__ = (#),
				__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
				(__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
				__WEBPACK_AMD_DEFINE_FACTORY__),
				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))`
			],
			af: [
				"var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;",
				`!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_RESULT__ = #.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))`
			],
			ao: [
				"",
				"!(#, module.exports = #)"
			],
			aof: [
				"var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;",
				`!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_FACTORY__ = (#),
				__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
				(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
				__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))`
			],
			lf: [
				"var XXX, XXXmodule;",
				"!(XXXmodule = { id: YYY, exports: {}, loaded: false }, XXX = #.call(XXXmodule.exports, __webpack_require__, XXXmodule.exports, XXXmodule), XXXmodule.loaded = true, XXX === undefined && (XXX = XXXmodule.exports))"
			],
			lo: [
				"var XXX;",
				"!(XXX = #)"
			],
			lof: [
				"var XXX, XXXfactory, XXXmodule;",
				"!(XXXfactory = (#), (XXXmodule = { id: YYY, exports: {}, loaded: false }), XXX = (typeof XXXfactory === 'function' ? (XXXfactory.call(XXXmodule.exports, __webpack_require__, XXXmodule.exports, XXXmodule)) : XXXfactory), (XXXmodule.loaded = true), XXX === undefined && (XXX = XXXmodule.exports))"
			],
			laf: [
				"var __WEBPACK_AMD_DEFINE_ARRAY__, XXX;",
				"!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, XXX = (#.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)))"
			],
			lao: [
				"var XXX;",
				"!(#, XXX = #)"
			],
			laof: [
				"var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_FACTORY__, XXX;",
				`!(__WEBPACK_AMD_DEFINE_ARRAY__ = #, __WEBPACK_AMD_DEFINE_FACTORY__ = (#),
				XXX = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
				(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__))`
			]
		};
	}
 
	apply(dependency, source) {
		const branch = this.branch(dependency);
		const defAndText = this.definitions[branch];
		const definitions = defAndText[0];
		const text = defAndText[1];
		this.replace(dependency, source, definitions, text);
	}
 
	localModuleVar(dependency) {
		return dependency.localModule && dependency.localModule.used && dependency.localModule.variableName();
	}
 
	branch(dependency) {
		const localModuleVar = this.localModuleVar(dependency) ? "l" : "";
		const arrayRange = dependency.arrayRange ? "a" : "";
		const objectRange = dependency.objectRange ? "o" : "";
		const functionRange = dependency.functionRange ? "f" : "";
		return localModuleVar + arrayRange + objectRange + functionRange;
	}
 
	replace(dependency, source, definition, text) {
		const localModuleVar = this.localModuleVar(dependency);
		if(localModuleVar) {
			text = text.replace(/XXX/g, localModuleVar.replace(/\$/g, "$$$$"));
			definition = definition.replace(/XXX/g, localModuleVar.replace(/\$/g, "$$$$"));
		}
 
		if(dependency.namedModule) {
			text = text.replace(/YYY/g, JSON.stringify(dependency.namedModule));
		}
 
		const texts = text.split("#");
 
		if(definition) source.insert(0, definition);
 
		let current = dependency.range[0];
		if(dependency.arrayRange) {
			source.replace(current, dependency.arrayRange[0] - 1, texts.shift());
			current = dependency.arrayRange[1];
		}
 
		if(dependency.objectRange) {
			source.replace(current, dependency.objectRange[0] - 1, texts.shift());
			current = dependency.objectRange[1];
		} else if(dependency.functionRange) {
			source.replace(current, dependency.functionRange[0] - 1, texts.shift());
			current = dependency.functionRange[1];
		}
		source.replace(current, dependency.range[1] - 1, texts.shift());
		if(texts.length > 0)
			throw new Error("Implementation error");
	}
};
 
module.exports = AMDDefineDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js

Statements: 5.62% (10 / 178)      Branches: 0% (0 / 122)      Functions: 0% (0 / 3)      Lines: 6.06% (10 / 165)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252            1 1 1 1 1 1 1 1   1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const AMDRequireItemDependency = require("./AMDRequireItemDependency");
const AMDRequireContextDependency = require("./AMDRequireContextDependency");
const ConstDependency = require("./ConstDependency");
const AMDDefineDependency = require("./AMDDefineDependency");
const AMDRequireArrayDependency = require("./AMDRequireArrayDependency");
const LocalModuleDependency = require("./LocalModuleDependency");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
const LocalModulesHelpers = require("./LocalModulesHelpers");
 
function isBoundFunctionExpression(expr) {
	if(expr.type !== "CallExpression") return false;
	if(expr.callee.type !== "MemberExpression") return false;
	if(expr.callee.computed) return false;
	if(expr.callee.object.type !== "FunctionExpression") return false;
	if(expr.callee.property.type !== "Identifier") return false;
	if(expr.callee.property.name !== "bind") return false;
	return true;
}
 
class AMDDefineDependencyParserPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(parser) {
		const options = this.options;
		parser.plugin("call define", (expr) => {
			let array, fn, obj, namedModule;
			switch(expr.arguments.length) {
				case 1:
					if(expr.arguments[0].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[0])) {
						// define(f() {...})
						fn = expr.arguments[0];
					} else if(expr.arguments[0].type === "ObjectExpression") {
						// define({...})
						obj = expr.arguments[0];
					} else {
						// define(expr)
						// unclear if function or object
						obj = fn = expr.arguments[0];
					}
					break;
				case 2:
					if(expr.arguments[0].type === "Literal") {
						namedModule = expr.arguments[0].value;
						// define("...", ...)
						if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) {
							// define("...", f() {...})
							fn = expr.arguments[1];
						} else if(expr.arguments[1].type === "ObjectExpression") {
							// define("...", {...})
							obj = expr.arguments[1];
						} else {
							// define("...", expr)
							// unclear if function or object
							obj = fn = expr.arguments[1];
						}
					} else {
						array = expr.arguments[0];
						if(expr.arguments[1].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[1])) {
							// define([...], f() {})
							fn = expr.arguments[1];
						} else if(expr.arguments[1].type === "ObjectExpression") {
							// define([...], {...})
							obj = expr.arguments[1];
						} else {
							// define([...], expr)
							// unclear if function or object
							obj = fn = expr.arguments[1];
						}
					}
					break;
				case 3:
					// define("...", [...], f() {...})
					namedModule = expr.arguments[0].value;
					array = expr.arguments[1];
					if(expr.arguments[2].type === "FunctionExpression" || isBoundFunctionExpression(expr.arguments[2])) {
						// define("...", [...], f() {})
						fn = expr.arguments[2];
					} else if(expr.arguments[2].type === "ObjectExpression") {
						// define("...", [...], {...})
						obj = expr.arguments[2];
					} else {
						// define("...", [...], expr)
						// unclear if function or object
						obj = fn = expr.arguments[2];
					}
					break;
				default:
					return;
			}
			let fnParams = null;
			let fnParamsOffset = 0;
			if(fn) {
				if(fn.type === "FunctionExpression") fnParams = fn.params;
				else if(isBoundFunctionExpression(fn)) {
					fnParams = fn.callee.object.params;
					fnParamsOffset = fn.arguments.length - 1;
					if(fnParamsOffset < 0) fnParamsOffset = 0;
				}
			}
			let fnRenames = Object.create(parser.scope.renames);
			let identifiers;
			if(array) {
				identifiers = {};
				const param = parser.evaluateExpression(array);
				const result = parser.applyPluginsBailResult("call define:amd:array", expr, param, identifiers, namedModule);
				if(!result) return;
				if(fnParams) fnParams = fnParams.slice(fnParamsOffset).filter((param, idx) => {
					if(identifiers[idx]) {
						fnRenames["$" + param.name] = identifiers[idx];
						return false;
					}
					return true;
				});
			} else {
				identifiers = ["require", "exports", "module"];
				if(fnParams) fnParams = fnParams.slice(fnParamsOffset).filter((param, idx) => {
					if(identifiers[idx]) {
						fnRenames["$" + param.name] = identifiers[idx];
						return false;
					}
					return true;
				});
			}
			let inTry;
			if(fn && fn.type === "FunctionExpression") {
				inTry = parser.scope.inTry;
				parser.inScope(fnParams, () => {
					parser.scope.renames = fnRenames;
					parser.scope.inTry = inTry;
					if(fn.body.type === "BlockStatement")
						parser.walkStatement(fn.body);
					else
						parser.walkExpression(fn.body);
				});
			} else if(fn && isBoundFunctionExpression(fn)) {
				inTry = parser.scope.inTry;
				parser.inScope(fn.callee.object.params.filter((i) => ["require", "module", "exports"].indexOf(i.name) < 0), () => {
					parser.scope.renames = fnRenames;
					parser.scope.inTry = inTry;
					if(fn.callee.object.body.type === "BlockStatement")
						parser.walkStatement(fn.callee.object.body);
					else
						parser.walkExpression(fn.callee.object.body);
				});
				if(fn.arguments)
					parser.walkExpressions(fn.arguments);
			} else if(fn || obj) {
				parser.walkExpression(fn || obj);
			}
 
			const dep = new AMDDefineDependency(
				expr.range,
				array ? array.range : null,
				fn ? fn.range : null,
				obj ? obj.range : null,
				namedModule ? namedModule : null
			);
			dep.loc = expr.loc;
			if(namedModule) {
				dep.localModule = LocalModulesHelpers.addLocalModule(parser.state, namedModule);
			}
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("call define:amd:array", (expr, param, identifiers, namedModule) => {
			if(param.isArray()) {
				param.items.forEach((param, idx) => {
					if(param.isString() && ["require", "module", "exports"].indexOf(param.string) >= 0)
						identifiers[idx] = param.string;
					const result = parser.applyPluginsBailResult("call define:amd:item", expr, param, namedModule);
					if(result === undefined) {
						parser.applyPluginsBailResult("call define:amd:context", expr, param);
					}
				});
				return true;
			} else if(param.isConstArray()) {
				const deps = [];
				param.array.forEach((request, idx) => {
					let dep;
					let localModule;
					if(request === "require") {
						identifiers[idx] = request;
						dep = "__webpack_require__";
					} else if(["exports", "module"].indexOf(request) >= 0) {
						identifiers[idx] = request;
						dep = request;
					} else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, request)) { // eslint-disable-line no-cond-assign
						dep = new LocalModuleDependency(localModule);
						dep.loc = expr.loc;
						parser.state.current.addDependency(dep);
					} else {
						dep = new AMDRequireItemDependency(request);
						dep.loc = expr.loc;
						dep.optional = !!parser.scope.inTry;
						parser.state.current.addDependency(dep);
					}
					deps.push(dep);
				});
				const dep = new AMDRequireArrayDependency(deps, param.range);
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call define:amd:item", (expr, param, namedModule) => {
			if(param.isConditional()) {
				param.options.forEach((param) => {
					const result = parser.applyPluginsBailResult("call define:amd:item", expr, param);
					if(result === undefined) {
						parser.applyPluginsBailResult("call define:amd:context", expr, param);
					}
				});
				return true;
			} else if(param.isString()) {
				let dep, localModule;
				if(param.string === "require") {
					dep = new ConstDependency("__webpack_require__", param.range);
				} else if(["require", "exports", "module"].indexOf(param.string) >= 0) {
					dep = new ConstDependency(param.string, param.range);
				} else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string, namedModule)) { // eslint-disable-line no-cond-assign
					dep = new LocalModuleDependency(localModule, param.range);
				} else {
					dep = new AMDRequireItemDependency(param.string, param.range);
				}
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call define:amd:context", (expr, param) => {
			const dep = ContextDependencyHelpers.create(AMDRequireContextDependency, param.range, param, expr, options);
			if(!dep) return;
			dep.loc = expr.loc;
			dep.optional = !!parser.scope.inTry;
			parser.state.current.addDependency(dep);
			return true;
		});
	}
}
module.exports = AMDDefineDependencyParserPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDPlugin.js

Statements: 22.06% (15 / 68)      Branches: 0% (0 / 4)      Functions: 0% (0 / 3)      Lines: 22.06% (15 / 68)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121            1 1 1 1 1 1 1 1   1   1 1   1   1                                                                                 1                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const path = require("path");
const AMDRequireDependency = require("./AMDRequireDependency");
const AMDRequireItemDependency = require("./AMDRequireItemDependency");
const AMDRequireArrayDependency = require("./AMDRequireArrayDependency");
const AMDRequireContextDependency = require("./AMDRequireContextDependency");
const AMDDefineDependency = require("./AMDDefineDependency");
const UnsupportedDependency = require("./UnsupportedDependency");
const LocalModuleDependency = require("./LocalModuleDependency");
 
const NullFactory = require("../NullFactory");
 
const AMDRequireDependenciesBlockParserPlugin = require("./AMDRequireDependenciesBlockParserPlugin");
const AMDDefineDependencyParserPlugin = require("./AMDDefineDependencyParserPlugin");
 
const AliasPlugin = require("enhanced-resolve/lib/AliasPlugin");
 
const ParserHelpers = require("../ParserHelpers");
 
class AMDPlugin {
	constructor(options, amdOptions) {
		this.amdOptions = amdOptions;
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		const amdOptions = this.amdOptions;
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
			const contextModuleFactory = params.contextModuleFactory;
 
			compilation.dependencyFactories.set(AMDRequireDependency, new NullFactory());
			compilation.dependencyTemplates.set(AMDRequireDependency, new AMDRequireDependency.Template());
 
			compilation.dependencyFactories.set(AMDRequireItemDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(AMDRequireItemDependency, new AMDRequireItemDependency.Template());
 
			compilation.dependencyFactories.set(AMDRequireArrayDependency, new NullFactory());
			compilation.dependencyTemplates.set(AMDRequireArrayDependency, new AMDRequireArrayDependency.Template());
 
			compilation.dependencyFactories.set(AMDRequireContextDependency, contextModuleFactory);
			compilation.dependencyTemplates.set(AMDRequireContextDependency, new AMDRequireContextDependency.Template());
 
			compilation.dependencyFactories.set(AMDDefineDependency, new NullFactory());
			compilation.dependencyTemplates.set(AMDDefineDependency, new AMDDefineDependency.Template());
 
			compilation.dependencyFactories.set(UnsupportedDependency, new NullFactory());
			compilation.dependencyTemplates.set(UnsupportedDependency, new UnsupportedDependency.Template());
 
			compilation.dependencyFactories.set(LocalModuleDependency, new NullFactory());
			compilation.dependencyTemplates.set(LocalModuleDependency, new LocalModuleDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.amd !== "undefined" && !parserOptions.amd)
					return;
 
				function setExpressionToModule(outerExpr, module) {
					parser.plugin("expression " + outerExpr, (expr) => {
						const dep = new AMDRequireItemDependency(module, expr.range);
						dep.userRequest = outerExpr;
						dep.loc = expr.loc;
						parser.state.current.addDependency(dep);
						return true;
					});
				}
 
				parser.apply(
					new AMDRequireDependenciesBlockParserPlugin(options),
					new AMDDefineDependencyParserPlugin(options)
				);
				setExpressionToModule("require.amd", "!!webpack amd options");
				setExpressionToModule("define.amd", "!!webpack amd options");
				setExpressionToModule("define", "!!webpack amd define");
				parser.plugin("expression __webpack_amd_options__", () =>
					parser.state.current.addVariable("__webpack_amd_options__", JSON.stringify(amdOptions)));
				parser.plugin("evaluate typeof define.amd", ParserHelpers.evaluateToString(typeof amdOptions));
				parser.plugin("evaluate typeof require.amd", ParserHelpers.evaluateToString(typeof amdOptions));
				parser.plugin("evaluate Identifier define.amd", ParserHelpers.evaluateToBoolean(true));
				parser.plugin("evaluate Identifier require.amd", ParserHelpers.evaluateToBoolean(true));
				parser.plugin("typeof define", ParserHelpers.toConstantDependency(JSON.stringify("function")));
				parser.plugin("evaluate typeof define", ParserHelpers.evaluateToString("function"));
				parser.plugin("can-rename define", ParserHelpers.approve);
				parser.plugin("rename define", (expr) => {
					const dep = new AMDRequireItemDependency("!!webpack amd define", expr.range);
					dep.userRequest = "define";
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
					return false;
				});
				parser.plugin("typeof require", ParserHelpers.toConstantDependency(JSON.stringify("function")));
				parser.plugin("evaluate typeof require", ParserHelpers.evaluateToString("function"));
			});
		});
		compiler.plugin("after-resolvers", () => {
			compiler.resolvers.normal.apply(
				new AliasPlugin("described-resolve", {
					name: "amdefine",
					alias: path.join(__dirname, "..", "..", "buildin", "amd-define.js")
				}, "resolve"),
				new AliasPlugin("described-resolve", {
					name: "webpack amd options",
					alias: path.join(__dirname, "..", "..", "buildin", "amd-options.js")
				}, "resolve"),
				new AliasPlugin("described-resolve", {
					name: "webpack amd define",
					alias: path.join(__dirname, "..", "..", "buildin", "amd-define.js")
				}, "resolve")
			);
		});
	}
}
module.exports = AMDPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireArrayDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireArrayDependency.js

Statements: 17.39% (4 / 23)      Branches: 0% (0 / 6)      Functions: 0% (0 / 6)      Lines: 17.39% (4 / 23)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58          1 1                           1                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
const webpackMissingModuleModule = require("./WebpackMissingModule").module;
 
class AMDRequireArrayDependency extends Dependency {
	constructor(depsArray, range) {
		super();
		this.depsArray = depsArray;
		this.range = range;
	}
 
	get type() {
		return "amd require array";
	}
}
 
AMDRequireArrayDependency.Template = class AMDRequireArrayDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const content = this.getContent(dep, outputOptions, requestShortener);
		source.replace(dep.range[0], dep.range[1] - 1, content);
	}
 
	getContent(dep, outputOptions, requestShortener) {
		const requires = dep.depsArray.map((dependency) => {
			const optionalComment = this.optionalComment(outputOptions.pathinfo, requestShortener.shorten(dependency.request));
			return this.contentForDependency(dependency, optionalComment);
		});
		return `[${requires.join(", ")}]`;
	}
 
	optionalComment(pathInfo, shortenedRequest) {
		if(!pathInfo) {
			return "";
		}
		return `/*! ${shortenedRequest} */ `;
	}
 
	contentForDependency(dep, comment) {
		if(typeof dep === "string") {
			return dep;
		}
 
		if(dep.module) {
			const stringifiedId = JSON.stringify(dep.module.id);
			return `__webpack_require__(${comment}${stringifiedId})`;
		}
 
		return webpackMissingModuleModule(dep.request);
	}
};
 
module.exports = AMDRequireArrayDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireContextDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireContextDependency.js

Statements: 40% (4 / 10)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 40% (4 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31            1 1                                       1 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ContextDependency = require("./ContextDependency");
const CriticalDependencyWarning = require("./CriticalDependencyWarning");
class AMDRequireContextDependency extends ContextDependency {
	constructor(request, recursive, regExp, range, valueRange) {
		super(request, recursive, regExp);
		this.range = range;
		this.valueRange = valueRange;
	}
 
	get type() {
		return "amd require context";
	}
 
	getWarnings() {
		if(this.critical) {
			return [
				new CriticalDependencyWarning(this.critical)
			];
		}
	}
}
AMDRequireContextDependency.Template = require("./ContextDependencyTemplateAsRequireCall");
module.exports = AMDRequireContextDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlock.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlock.js

Statements: 13.64% (3 / 22)      Branches: 0% (0 / 13)      Functions: 0% (0 / 1)      Lines: 13.64% (3 / 22)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35          1 1   1                                                    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
const AMDRequireDependency = require("./AMDRequireDependency");
 
module.exports = class AMDRequireDependenciesBlock extends AsyncDependenciesBlock {
	constructor(expr, arrayRange, functionRange, errorCallbackRange, module, loc) {
		super(null, module, loc);
		this.expr = expr;
		this.outerRange = expr.range;
		this.arrayRange = arrayRange;
		this.functionRange = functionRange;
		this.errorCallbackRange = errorCallbackRange;
		this.bindThis = true;
		if(arrayRange && functionRange && errorCallbackRange) {
			this.range = [arrayRange[0], errorCallbackRange[1]];
		} else if(arrayRange && functionRange) {
			this.range = [arrayRange[0], functionRange[1]];
		} else if(arrayRange) {
			this.range = arrayRange;
		} else if(functionRange) {
			this.range = functionRange;
		} else {
			this.range = expr.range;
		}
		const dep = new AMDRequireDependency(this);
		dep.loc = loc;
		this.addDependency(dep);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js

Statements: 9.92% (12 / 121)      Branches: 0% (0 / 60)      Functions: 0% (0 / 3)      Lines: 10.08% (12 / 119)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » AMDRequireDependenciesBlockParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179            1 1 1 1 1 1 1 1 1 1 1                                                                                                                                                                                                                                                                                                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const AMDRequireItemDependency = require("./AMDRequireItemDependency");
const AMDRequireArrayDependency = require("./AMDRequireArrayDependency");
const AMDRequireContextDependency = require("./AMDRequireContextDependency");
const AMDRequireDependenciesBlock = require("./AMDRequireDependenciesBlock");
const UnsupportedDependency = require("./UnsupportedDependency");
const LocalModuleDependency = require("./LocalModuleDependency");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
const LocalModulesHelpers = require("./LocalModulesHelpers");
const ConstDependency = require("./ConstDependency");
const getFunctionExpression = require("./getFunctionExpression");
const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
 
class AMDRequireDependenciesBlockParserPlugin {
	constructor(options) {
		this.options = options;
	}
 
	processFunctionArgument(parser, expression) {
		let bindThis = true;
		const fnData = getFunctionExpression(expression);
		if(fnData) {
			parser.inScope(fnData.fn.params.filter((i) => {
				return ["require", "module", "exports"].indexOf(i.name) < 0;
			}), () => {
				if(fnData.fn.body.type === "BlockStatement")
					parser.walkStatement(fnData.fn.body);
				else
					parser.walkExpression(fnData.fn.body);
			});
			parser.walkExpressions(fnData.expressions);
			if(fnData.needThis === false) {
				bindThis = false;
			}
		} else {
			parser.walkExpression(expression);
		}
		return bindThis;
	}
 
	apply(parser) {
		const options = this.options;
		parser.plugin("call require", (expr) => {
			let param;
			let dep;
			let result;
 
			const old = parser.state.current;
 
			if(expr.arguments.length >= 1) {
				param = parser.evaluateExpression(expr.arguments[0]);
				dep = new AMDRequireDependenciesBlock(
					expr,
					param.range,
					(expr.arguments.length > 1) ? expr.arguments[1].range : null,
					(expr.arguments.length > 2) ? expr.arguments[2].range : null,
					parser.state.module,
					expr.loc
				);
				parser.state.current = dep;
			}
 
			if(expr.arguments.length === 1) {
				parser.inScope([], () => {
					result = parser.applyPluginsBailResult("call require:amd:array", expr, param);
				});
				parser.state.current = old;
				if(!result) return;
				parser.state.current.addBlock(dep);
				return true;
			}
 
			if(expr.arguments.length === 2 || expr.arguments.length === 3) {
				try {
					parser.inScope([], () => {
						result = parser.applyPluginsBailResult("call require:amd:array", expr, param);
					});
					if(!result) {
						dep = new UnsupportedDependency("unsupported", expr.range);
						old.addDependency(dep);
						if(parser.state.module)
							parser.state.module.errors.push(new UnsupportedFeatureWarning(parser.state.module, "Cannot statically analyse 'require(..., ...)' in line " + expr.loc.start.line));
						dep = null;
						return true;
					}
					dep.functionBindThis = this.processFunctionArgument(parser, expr.arguments[1]);
					if(expr.arguments.length === 3) {
						dep.errorCallbackBindThis = this.processFunctionArgument(parser, expr.arguments[2]);
					}
				} finally {
					parser.state.current = old;
					if(dep)
						parser.state.current.addBlock(dep);
				}
				return true;
			}
		});
		parser.plugin("call require:amd:array", (expr, param) => {
			if(param.isArray()) {
				param.items.forEach((param) => {
					const result = parser.applyPluginsBailResult("call require:amd:item", expr, param);
					if(result === undefined) {
						parser.applyPluginsBailResult("call require:amd:context", expr, param);
					}
				});
				return true;
			} else if(param.isConstArray()) {
				const deps = [];
				param.array.forEach((request) => {
					let dep, localModule;
					if(request === "require") {
						dep = "__webpack_require__";
					} else if(["exports", "module"].indexOf(request) >= 0) {
						dep = request;
					} else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, request)) { // eslint-disable-line no-cond-assign
						dep = new LocalModuleDependency(localModule);
						dep.loc = expr.loc;
						parser.state.current.addDependency(dep);
					} else {
						dep = new AMDRequireItemDependency(request);
						dep.loc = expr.loc;
						dep.optional = !!parser.scope.inTry;
						parser.state.current.addDependency(dep);
					}
					deps.push(dep);
				});
				const dep = new AMDRequireArrayDependency(deps, param.range);
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call require:amd:item", (expr, param) => {
			if(param.isConditional()) {
				param.options.forEach((param) => {
					const result = parser.applyPluginsBailResult("call require:amd:item", expr, param);
					if(result === undefined) {
						parser.applyPluginsBailResult("call require:amd:context", expr, param);
					}
				});
				return true;
			} else if(param.isString()) {
				let dep, localModule;
				if(param.string === "require") {
					dep = new ConstDependency("__webpack_require__", param.string);
				} else if(param.string === "module") {
					dep = new ConstDependency(parser.state.module.moduleArgument || "module", param.range);
				} else if(param.string === "exports") {
					dep = new ConstDependency(parser.state.module.exportsArgument || "exports", param.range);
				} else if(localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string)) { // eslint-disable-line no-cond-assign
					dep = new LocalModuleDependency(localModule, param.range);
				} else {
					dep = new AMDRequireItemDependency(param.string, param.range);
				}
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call require:amd:context", (expr, param) => {
			const dep = ContextDependencyHelpers.create(AMDRequireContextDependency, param.range, param, expr, options);
			if(!dep) return;
			dep.loc = expr.loc;
			dep.optional = !!parser.scope.inTry;
			parser.state.current.addDependency(dep);
			return true;
		});
	}
}
module.exports = AMDRequireDependenciesBlockParserPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireDependency.js

Statements: 10.26% (4 / 39)      Branches: 0% (0 / 23)      Functions: 0% (0 / 2)      Lines: 10.26% (4 / 39)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69          1 1                 1                                                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
const DepBlockHelpers = require("./DepBlockHelpers");
 
class AMDRequireDependency extends NullDependency {
	constructor(block) {
		super();
		this.block = block;
	}
}
 
AMDRequireDependency.Template = class AMDRequireDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const depBlock = dep.block;
		const wrapper = DepBlockHelpers.getLoadDepBlockWrapper(depBlock, outputOptions, requestShortener, "require");
 
		// has array range but no function range
		if(depBlock.arrayRange && !depBlock.functionRange) {
			const startBlock = wrapper[0] + "function() {";
			const endBlock = `;}${wrapper[1]}__webpack_require__.oe${wrapper[2]}`;
			source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock);
			source.replace(depBlock.arrayRange[1], depBlock.outerRange[1] - 1, endBlock);
			return;
		}
 
		// has function range but no array range
		if(depBlock.functionRange && !depBlock.arrayRange) {
			const startBlock = wrapper[0] + "function() {(";
			const endBlock = `.call(exports, __webpack_require__, exports, module));}${wrapper[1]}__webpack_require__.oe${wrapper[2]}`;
			source.replace(depBlock.outerRange[0], depBlock.functionRange[0] - 1, startBlock);
			source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, endBlock);
			return;
		}
 
		// has array range, function range, and errorCallbackRange
		if(depBlock.arrayRange && depBlock.functionRange && depBlock.errorCallbackRange) {
			const startBlock = wrapper[0] + "function() { ";
			const errorRangeBlock = `}${depBlock.functionBindThis ? ".bind(this)" : ""}${wrapper[1]}`;
			const endBlock = `${depBlock.errorCallbackBindThis ? ".bind(this)" : ""}${wrapper[2]}`;
 
			source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock);
			source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
			source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
			source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
			source.replace(depBlock.functionRange[1], depBlock.errorCallbackRange[0] - 1, errorRangeBlock);
			source.replace(depBlock.errorCallbackRange[1], depBlock.outerRange[1] - 1, endBlock);
			return;
		}
 
		// has array range, function range, but no errorCallbackRange
		if(depBlock.arrayRange && depBlock.functionRange) {
			const startBlock = wrapper[0] + "function() { ";
			const endBlock = `}${depBlock.functionBindThis ? ".bind(this)" : ""}${wrapper[1]}__webpack_require__.oe${wrapper[2]}`;
			source.replace(depBlock.outerRange[0], depBlock.arrayRange[0] - 1, startBlock);
			source.insert(depBlock.arrayRange[0] + 0.9, "var __WEBPACK_AMD_REQUIRE_ARRAY__ = ");
			source.replace(depBlock.arrayRange[1], depBlock.functionRange[0] - 1, "; (");
			source.insert(depBlock.functionRange[1], ".apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));");
			source.replace(depBlock.functionRange[1], depBlock.outerRange[1] - 1, endBlock);
		}
	}
};
 
module.exports = AMDRequireDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireItemDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/AMDRequireItemDependency.js

Statements: 57.14% (4 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 57.14% (4 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24          1 1                         1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateAsRequireId");
 
class AMDRequireItemDependency extends ModuleDependency {
	constructor(request, range) {
		super(request);
		this.range = range;
	}
 
	get type() {
		return "amd require";
	}
}
 
AMDRequireItemDependency.Template = ModuleDependencyTemplateAsRequireId;
 
module.exports = AMDRequireItemDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsPlugin.js

Statements: 22.22% (12 / 54)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 23.08% (12 / 52)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90          1 1 1 1 1 1 1   1   1 1   1                                                                                                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ConstDependency = require("./ConstDependency");
const CommonJsRequireDependency = require("./CommonJsRequireDependency");
const CommonJsRequireContextDependency = require("./CommonJsRequireContextDependency");
const RequireResolveDependency = require("./RequireResolveDependency");
const RequireResolveContextDependency = require("./RequireResolveContextDependency");
const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");
const RequireHeaderDependency = require("./RequireHeaderDependency");
 
const NullFactory = require("../NullFactory");
 
const RequireResolveDependencyParserPlugin = require("./RequireResolveDependencyParserPlugin");
const CommonJsRequireDependencyParserPlugin = require("./CommonJsRequireDependencyParserPlugin");
 
const ParserHelpers = require("../ParserHelpers");
 
class CommonJsPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
			const contextModuleFactory = params.contextModuleFactory;
 
			compilation.dependencyFactories.set(CommonJsRequireDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(CommonJsRequireDependency, new CommonJsRequireDependency.Template());
 
			compilation.dependencyFactories.set(CommonJsRequireContextDependency, contextModuleFactory);
			compilation.dependencyTemplates.set(CommonJsRequireContextDependency, new CommonJsRequireContextDependency.Template());
 
			compilation.dependencyFactories.set(RequireResolveDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(RequireResolveDependency, new RequireResolveDependency.Template());
 
			compilation.dependencyFactories.set(RequireResolveContextDependency, contextModuleFactory);
			compilation.dependencyTemplates.set(RequireResolveContextDependency, new RequireResolveContextDependency.Template());
 
			compilation.dependencyFactories.set(RequireResolveHeaderDependency, new NullFactory());
			compilation.dependencyTemplates.set(RequireResolveHeaderDependency, new RequireResolveHeaderDependency.Template());
 
			compilation.dependencyFactories.set(RequireHeaderDependency, new NullFactory());
			compilation.dependencyTemplates.set(RequireHeaderDependency, new RequireHeaderDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.commonjs !== "undefined" && !parserOptions.commonjs)
					return;
 
				const requireExpressions = ["require", "require.resolve", "require.resolveWeak"];
				for(let expression of requireExpressions) {
					parser.plugin(`typeof ${expression}`, ParserHelpers.toConstantDependency("function"));
					parser.plugin(`evaluate typeof ${expression}`, ParserHelpers.evaluateToString("function"));
				}
 
				parser.plugin("evaluate typeof module", ParserHelpers.evaluateToString("object"));
				parser.plugin("assign require", (expr) => {
					// to not leak to global "require", we need to define a local require here.
					const dep = new ConstDependency("var require;", 0);
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
					parser.scope.definitions.push("require");
					return true;
				});
				parser.plugin("can-rename require", () => true);
				parser.plugin("rename require", (expr) => {
					// define the require variable. It's still undefined, but not "not defined".
					const dep = new ConstDependency("var require;", 0);
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
					return false;
				});
				parser.plugin("typeof module", () => true);
				parser.plugin("evaluate typeof exports", ParserHelpers.evaluateToString("object"));
				parser.apply(
					new CommonJsRequireDependencyParserPlugin(options),
					new RequireResolveDependencyParserPlugin(options)
				);
			});
		});
	}
}
module.exports = CommonJsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsRequireContextDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsRequireContextDependency.js

Statements: 41.67% (5 / 12)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 41.67% (5 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36          1 1 1                                               1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ContextDependency = require("./ContextDependency");
const CriticalDependencyWarning = require("./CriticalDependencyWarning");
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
 
class CommonJsRequireContextDependency extends ContextDependency {
	constructor(request, recursive, regExp, range, valueRange) {
		super(request, recursive, regExp);
		this.range = range;
		this.valueRange = valueRange;
	}
 
	get type() {
		return "cjs require context";
	}
 
	getWarnings() {
		if(!this.critical) {
			return;
		}
 
		return [
			new CriticalDependencyWarning(this.critical)
		];
	}
}
 
CommonJsRequireContextDependency.Template = ContextDependencyTemplateAsRequireCall;
 
module.exports = CommonJsRequireContextDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsRequireDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsRequireDependency.js

Statements: 57.14% (4 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 57.14% (4 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24          1 1                         1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const ModuleDependencyTemplateAsId = require("./ModuleDependencyTemplateAsId");
 
class CommonJsRequireDependency extends ModuleDependency {
	constructor(request, range) {
		super(request);
		this.range = range;
	}
 
	get type() {
		return "cjs require";
	}
}
 
CommonJsRequireDependency.Template = ModuleDependencyTemplateAsId;
 
module.exports = CommonJsRequireDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsRequireDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CommonJsRequireDependencyParserPlugin.js

Statements: 12.7% (8 / 63)      Branches: 0% (0 / 20)      Functions: 0% (0 / 3)      Lines: 13.11% (8 / 61)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » CommonJsRequireDependencyParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91            1 1 1 1 1 1 1                                                                                                                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const CommonJsRequireDependency = require("./CommonJsRequireDependency");
const CommonJsRequireContextDependency = require("./CommonJsRequireContextDependency");
const RequireHeaderDependency = require("./RequireHeaderDependency");
const LocalModuleDependency = require("./LocalModuleDependency");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
const LocalModulesHelpers = require("./LocalModulesHelpers");
const ParserHelpers = require("../ParserHelpers");
 
class CommonJsRequireDependencyParserPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(parser) {
		const options = this.options;
		parser.plugin("expression require.cache", ParserHelpers.toConstantDependency("__webpack_require__.c"));
		parser.plugin("expression require", (expr) => {
			const dep = new CommonJsRequireContextDependency(options.unknownContextRequest, options.unknownContextRecursive, options.unknownContextRegExp, expr.range);
			dep.critical = options.unknownContextCritical && "require function is used in a way in which dependencies cannot be statically extracted";
			dep.loc = expr.loc;
			dep.optional = !!parser.scope.inTry;
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("call require", (expr) => {
			if(expr.arguments.length !== 1) return;
			let localModule;
			const param = parser.evaluateExpression(expr.arguments[0]);
			if(param.isConditional()) {
				let isExpression = false;
				const prevLength = parser.state.current.dependencies.length;
				const dep = new RequireHeaderDependency(expr.callee.range);
				dep.loc = expr.loc;
				parser.state.current.addDependency(dep);
				param.options.forEach(function(param) {
					const result = parser.applyPluginsBailResult("call require:commonjs:item", expr, param);
					if(result === undefined) {
						isExpression = true;
					}
				});
				if(isExpression) {
					parser.state.current.dependencies.length = prevLength;
				} else {
					return true;
				}
			}
			if(param.isString() && (localModule = LocalModulesHelpers.getLocalModule(parser.state, param.string))) {
				const dep = new LocalModuleDependency(localModule, expr.range);
				dep.loc = expr.loc;
				parser.state.current.addDependency(dep);
				return true;
			} else {
				const result = parser.applyPluginsBailResult("call require:commonjs:item", expr, param);
				if(result === undefined) {
					parser.applyPluginsBailResult("call require:commonjs:context", expr, param);
				} else {
					const dep = new RequireHeaderDependency(expr.callee.range);
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
				}
				return true;
			}
		});
		parser.plugin("call require:commonjs:item", (expr, param) => {
			if(param.isString()) {
				const dep = new CommonJsRequireDependency(param.string, param.range);
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call require:commonjs:context", (expr, param) => {
			const dep = ContextDependencyHelpers.create(CommonJsRequireContextDependency, expr.range, param, expr, options);
			if(!dep) return;
			dep.loc = expr.loc;
			dep.optional = !!parser.scope.inTry;
			parser.state.current.addDependency(dep);
			return true;
		});
	}
}
module.exports = CommonJsRequireDependencyParserPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ConstDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ConstDependency.js

Statements: 25% (3 / 12)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 25% (3 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34          1                             1                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class ConstDependency extends NullDependency {
	constructor(expression, range) {
		super();
		this.expression = expression;
		this.range = range;
	}
 
	updateHash(hash) {
		hash.update(this.range + "");
		hash.update(this.expression + "");
	}
}
 
ConstDependency.Template = class ConstDependencyTemplate {
	apply(dep, source) {
		if(typeof dep.range === "number") {
			source.insert(dep.range, dep.expression);
			return;
		}
 
		source.replace(dep.range[0], dep.range[1] - 1, dep.expression);
	}
};
 
module.exports = ConstDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependency.js

Statements: 18.18% (2 / 11)      Branches: 0% (0 / 6)      Functions: 0% (0 / 2)      Lines: 18.18% (2 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31          1                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
 
class ContextDependency extends Dependency {
	constructor(request, recursive, regExp) {
		super();
		this.request = request;
		this.userRequest = request;
		this.recursive = recursive;
		this.regExp = regExp;
		this.async = false;
	}
 
	isEqualResource(other) {
		if(!(other instanceof ContextDependency))
			return false;
 
		return this.request === other.request &&
			this.recursive === other.recursive &&
			this.regExp === other.regExp &&
			this.async === other.async;
	}
}
 
module.exports = ContextDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependencyHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependencyHelpers.js

Statements: 6.25% (3 / 48)      Branches: 0% (0 / 39)      Functions: 0% (0 / 2)      Lines: 6.25% (3 / 48)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73            1             1       1                                                                                                              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ContextDependencyHelpers = exports;
 
/**
 * Escapes regular expression metacharacters
 * @param {string} str String to quote
 * @return {string} Escaped string
 */
function quotemeta(str) {
	return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
}
 
ContextDependencyHelpers.create = function(Dep, range, param, expr, options, chunkName) {
	let dep;
	let prefix;
	let postfix;
	let prefixRange;
	let valueRange;
	let idx;
	let context;
	let regExp;
	if(param.isTemplateString()) {
		prefix = param.quasis[0].string;
		postfix = param.quasis.length > 1 ? param.quasis[param.quasis.length - 1].string : "";
		prefixRange = [param.quasis[0].range[0], param.quasis[0].range[1]];
		valueRange = param.range;
		idx = prefix.lastIndexOf("/");
		context = ".";
		if(idx >= 0) {
			context = prefix.substr(0, idx);
			prefix = `.${prefix.substr(idx)}`;
		}
		// If there are more than two quasis, maybe the generated RegExp can be more precise?
		regExp = new RegExp(`^${quotemeta(prefix)}${options.wrappedContextRegExp.source}${quotemeta(postfix)}$`);
		dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange, chunkName);
		dep.loc = expr.loc;
		dep.replaces = [{
			range: prefixRange,
			value: prefix
		}];
		dep.critical = options.wrappedContextCritical && "a part of the request of a dependency is an expression";
		return dep;
	} else if(param.isWrapped() && (param.prefix && param.prefix.isString() || param.postfix && param.postfix.isString())) {
		prefix = param.prefix && param.prefix.isString() ? param.prefix.string : "";
		postfix = param.postfix && param.postfix.isString() ? param.postfix.string : "";
		prefixRange = param.prefix && param.prefix.isString() ? param.prefix.range : null;
		valueRange = [prefixRange ? prefixRange[1] : param.range[0], param.range[1]];
		idx = prefix.lastIndexOf("/");
		context = ".";
		if(idx >= 0) {
			context = prefix.substr(0, idx);
			prefix = `.${prefix.substr(idx)}`;
		}
		regExp = new RegExp(`^${quotemeta(prefix)}${options.wrappedContextRegExp.source}${quotemeta(postfix)}$`);
		dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange, chunkName);
		dep.loc = expr.loc;
		dep.prepend = param.prefix && param.prefix.isString() ? prefix : null;
		dep.critical = options.wrappedContextCritical && "a part of the request of a dependency is an expression";
		return dep;
	} else {
		dep = new Dep(options.exprContextRequest, options.exprContextRecursive, options.exprContextRegExp, range, param.range, chunkName);
		dep.loc = expr.loc;
		dep.critical = options.exprContextCritical && "the request of a dependency is an expression";
		return dep;
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependencyTemplateAsId.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependencyTemplateAsId.js

Statements: 7.69% (1 / 13)      Branches: 0% (0 / 13)      Functions: 0% (0 / 1)      Lines: 7.69% (1 / 13)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34                                                              1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class ContextDependencyTemplateAsId {
 
	apply(dep, source, outputOptions, requestShortener) {
		const comment = outputOptions.pathinfo ?
			"/*! " + requestShortener.shorten(dep.request) + " */ " : "";
 
		if(dep.module && dep.module.dependencies && dep.module.dependencies.length > 0) {
			if(dep.valueRange) {
				if(Array.isArray(dep.replaces)) {
					for(let i = 0; i < dep.replaces.length; i++) {
						const rep = dep.replaces[i];
						source.replace(rep.range[0], rep.range[1] - 1, rep.value);
					}
				}
				source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
				source.replace(dep.range[0], dep.valueRange[0] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ").resolve(" + (typeof dep.prepend === "string" ? JSON.stringify(dep.prepend) : "") + "");
			} else {
				source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ").resolve");
			}
		} else {
			const content = require("./WebpackMissingModule").module(dep.request);
			source.replace(dep.range[0], dep.range[1] - 1, content);
		}
	}
}
module.exports = ContextDependencyTemplateAsId;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependencyTemplateAsRequireCall.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextDependencyTemplateAsRequireCall.js

Statements: 6.67% (1 / 15)      Branches: 0% (0 / 18)      Functions: 0% (0 / 1)      Lines: 6.67% (1 / 15)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » ContextDependencyTemplateAsRequireCall.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                  1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class ContextDependencyTemplateAsRequireCall {
 
	apply(dep, source, outputOptions, requestShortener) {
		const comment = outputOptions.pathinfo ?
			"/*! " + requestShortener.shorten(dep.request) + " */ " : "";
 
		const containsDeps = dep.module && dep.module.dependencies && dep.module.dependencies.length > 0;
		const isAsync = dep.module && dep.module.async;
		if(dep.module && (isAsync || containsDeps)) {
			if(dep.valueRange) {
				if(Array.isArray(dep.replaces)) {
					for(let i = 0; i < dep.replaces.length; i++) {
						const rep = dep.replaces[i];
						source.replace(rep.range[0], rep.range[1] - 1, rep.value);
					}
				}
				source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
				source.replace(dep.range[0], dep.valueRange[0] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ")(" + (typeof dep.prepend === "string" ? JSON.stringify(dep.prepend) : "") + "");
			} else {
				source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__(" + comment + JSON.stringify(dep.module.id) + ")");
			}
		} else {
			const content = require("./WebpackMissingModule").module(dep.request);
			source.replace(dep.range[0], dep.range[1] - 1, content);
		}
	}
}
module.exports = ContextDependencyTemplateAsRequireCall;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextElementDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ContextElementDependency.js

Statements: 33.33% (2 / 6)      Branches: 0% (0 / 2)      Functions: 0% (0 / 2)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23          1                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
 
class ContextElementDependency extends ModuleDependency {
	constructor(request, userRequest) {
		super(request);
		if(userRequest) {
			this.userRequest = userRequest;
		}
	}
 
	get type() {
		return "context element";
	}
}
 
module.exports = ContextElementDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CriticalDependencyWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/CriticalDependencyWarning.js

Statements: 33.33% (2 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22            1                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const WebpackError = require("../WebpackError");
 
class CriticalDependencyWarning extends WebpackError {
	constructor(message) {
		super();
 
		this.name = "CriticalDependencyWarning";
		this.message = "Critical dependency: " + message;
 
		Error.captureStackTrace(this, this.constructor);
	}
}
 
module.exports = CriticalDependencyWarning;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DelegatedSourceDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DelegatedSourceDependency.js

Statements: 50% (2 / 4)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (2 / 4)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
 
class DelegatedSourceDependency extends ModuleDependency {
	constructor(request) {
		super(request);
	}
 
	get type() {
		return "delegated source";
	}
}
 
module.exports = DelegatedSourceDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DepBlockHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DepBlockHelpers.js

Statements: 21.05% (4 / 19)      Branches: 0% (0 / 18)      Functions: 0% (0 / 5)      Lines: 22.22% (4 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44        1   1                 1                                             1          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
var DepBlockHelpers = exports;
 
DepBlockHelpers.getLoadDepBlockWrapper = function(depBlock, outputOptions, requestShortener, name) {
	var promiseCode = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, name);
	return [
		promiseCode + ".then(",
		").catch(",
		")"
	];
};
 
DepBlockHelpers.getDepBlockPromise = function(depBlock, outputOptions, requestShortener, name) {
	if(depBlock.chunks) {
		var chunks = depBlock.chunks.filter(function(chunk) {
			return !chunk.hasRuntime() && chunk.id !== null;
		});
		if(chunks.length === 1) {
			var chunk = chunks[0];
			return "__webpack_require__.e" + asComment(name) + "(" + JSON.stringify(chunk.id) + "" +
				(outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
				asComment(depBlock.chunkReason) + ")";
		} else if(chunks.length > 0) {
			return "Promise.all" + asComment(name) + "(" +
				(outputOptions.pathinfo && depBlock.chunkName ? "/*! " + requestShortener.shorten(depBlock.chunkName) + " */" : "") +
				"[" +
				chunks.map(function(chunk) {
					return "__webpack_require__.e(" + JSON.stringify(chunk.id) + ")";
				}).join(", ") +
				"])";
		}
	}
	return "Promise.resolve()";
};
 
function asComment(str) {
	if(!str) return "";
	return "/* " + str + " */";
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DllEntryDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/DllEntryDependency.js

Statements: 33.33% (2 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22          1                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
 
class DllEntryDependency extends Dependency {
	constructor(dependencies, name) {
		super();
		this.dependencies = dependencies;
		this.name = name;
	}
 
	get type() {
		return "dll entry";
	}
}
 
module.exports = DllEntryDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyAcceptDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyAcceptDependency.js

Statements: 25% (4 / 16)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 25% (4 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44          1 1                             1                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
const makeHarmonyImportStatement = require("./HarmonyImportDependency").makeImportStatement;
 
class HarmonyAcceptDependency extends NullDependency {
	constructor(range, dependencies, hasCallback) {
		super();
		this.range = range;
		this.dependencies = dependencies;
		this.hasCallback = hasCallback;
	}
 
	get type() {
		return "accepted harmony modules";
	}
}
 
HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const content = dep.dependencies
			.map(dependency => makeHarmonyImportStatement(
				false,
				dependency,
				outputOptions,
				requestShortener
			)).join("");
 
		if(dep.hasCallback) {
			source.insert(dep.range[0], `function(__WEBPACK_OUTDATED_DEPENDENCIES__) { ${content}(`);
			source.insert(dep.range[1], ")(__WEBPACK_OUTDATED_DEPENDENCIES__); }");
			return;
		}
 
		source.insert(dep.range[1] - 0.5, `, function() { ${content} }`);
	}
};
 
module.exports = HarmonyAcceptDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyAcceptImportDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyAcceptImportDependency.js

Statements: 60% (3 / 5)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 60% (3 / 5)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24          1                       1       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const HarmonyImportDependency = require("./HarmonyImportDependency");
 
class HarmonyAcceptImportDependency extends HarmonyImportDependency {
	constructor(request, importedVar, range) {
		super(request, importedVar, range);
	}
 
	get type() {
		return "harmony accept";
	}
}
 
HarmonyAcceptImportDependency.Template = class HarmonyAcceptImportDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {}
};
 
module.exports = HarmonyAcceptImportDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js

Statements: 27.27% (3 / 11)      Branches: 0% (0 / 6)      Functions: 0% (0 / 3)      Lines: 27.27% (3 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32          1                         1                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class HarmonyCompatibilityDependency extends NullDependency {
	constructor(originModule) {
		super();
		this.originModule = originModule;
	}
 
	get type() {
		return "harmony export header";
	}
}
 
HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate {
	apply(dep, source) {
		const usedExports = dep.originModule.usedExports;
		if(usedExports && !Array.isArray(usedExports)) {
			const exportName = dep.originModule.exportsArgument || "exports";
			const content = `Object.defineProperty(${exportName}, \"__esModule\", { value: true });\n`;
			source.insert(-1, content);
		}
	}
};
 
module.exports = HarmonyCompatibilityDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyDetectionParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyDetectionParserPlugin.js

Statements: 14.29% (4 / 28)      Branches: 0% (0 / 12)      Functions: 0% (0 / 3)      Lines: 14.29% (4 / 28)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58            1   1                                                                     1           1                
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
 
module.exports = class HarmonyDetectionParserPlugin {
	apply(parser) {
		parser.plugin("program", (ast) => {
			var isHarmony = ast.body.some(statement => {
				return /^(Import|Export).*Declaration$/.test(statement.type);
			});
			if(isHarmony) {
				const module = parser.state.module;
				const dep = new HarmonyCompatibilityDependency(module);
				dep.loc = {
					start: {
						line: -1,
						column: 0
					},
					end: {
						line: -1,
						column: 0
					},
					index: -2
				};
				module.addDependency(dep);
				module.meta.harmonyModule = true;
				module.strict = true;
				module.exportsArgument = "__webpack_exports__";
			}
		});
		var nonHarmonyIdentifiers = ["define", "exports"];
		nonHarmonyIdentifiers.forEach(identifer => {
			parser.plugin(`evaluate typeof ${identifer}`, nullInHarmony);
			parser.plugin(`typeof ${identifer}`, skipInHarmony);
			parser.plugin(`evaluate ${identifer}`, nullInHarmony);
			parser.plugin(`expression ${identifer}`, skipInHarmony);
			parser.plugin(`call ${identifer}`, skipInHarmony);
		});
 
		function skipInHarmony() {
			const module = this.state.module;
			if(module && module.meta && module.meta.harmonyModule)
				return true;
		}
 
		function nullInHarmony() {
			const module = this.state.module;
			if(module && module.meta && module.meta.harmonyModule)
				return null;
		}
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js

Statements: 15.52% (9 / 58)      Branches: 0% (0 / 22)      Functions: 0% (0 / 3)      Lines: 16.67% (9 / 54)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » HarmonyExportDependencyParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77            1 1 1 1 1 1   1                                                                                                     1             1          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency");
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
const HarmonyImportDependency = require("./HarmonyImportDependency");
const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
 
module.exports = class HarmonyExportDependencyParserPlugin {
	apply(parser) {
		parser.plugin("export", statement => {
			const dep = new HarmonyExportHeaderDependency(statement.declaration && statement.declaration.range, statement.range);
			dep.loc = Object.create(statement.loc);
			dep.loc.index = -1;
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("export import", (statement, source) => {
			const dep = new HarmonyImportDependency(source, HarmonyModulesHelpers.getNewModuleVar(parser.state, source), statement.range);
			dep.loc = Object.create(statement.loc);
			dep.loc.index = -1;
			parser.state.current.addDependency(dep);
			parser.state.lastHarmonyImport = dep;
			return true;
		});
		parser.plugin("export expression", (statement, expr) => {
			const dep = new HarmonyExportExpressionDependency(parser.state.module, expr.range, statement.range);
			dep.loc = Object.create(statement.loc);
			dep.loc.index = -1;
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("export declaration", statement => {});
		parser.plugin("export specifier", (statement, id, name, idx) => {
			const rename = parser.scope.renames[`$${id}`];
			let dep;
			if(rename === "imported var") {
				const settings = parser.state.harmonySpecifier[`$${id}`];
				dep = new HarmonyExportImportedSpecifierDependency(parser.state.module, settings[0], settings[1], settings[2], name);
			} else {
				const immutable = statement.declaration && isImmutableStatement(statement.declaration);
				const hoisted = statement.declaration && isHoistedStatement(statement.declaration);
				dep = new HarmonyExportSpecifierDependency(parser.state.module, id, name, !immutable || hoisted ? -0.5 : (statement.range[1] + 0.5), immutable);
			}
			dep.loc = Object.create(statement.loc);
			dep.loc.index = idx;
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("export import specifier", (statement, source, id, name, idx) => {
			const dep = new HarmonyExportImportedSpecifierDependency(parser.state.module, parser.state.lastHarmonyImport, HarmonyModulesHelpers.getModuleVar(parser.state, source), id, name);
			dep.loc = Object.create(statement.loc);
			dep.loc.index = idx;
			parser.state.current.addDependency(dep);
			return true;
		});
	}
};
 
function isImmutableStatement(statement) {
	if(statement.type === "FunctionDeclaration") return true;
	if(statement.type === "ClassDeclaration") return true;
	if(statement.type === "VariableDeclaration" && statement.kind === "const") return true;
	return false;
}
 
function isHoistedStatement(statement) {
	if(statement.type === "FunctionDeclaration") return true;
	return false;
}
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportExpressionDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportExpressionDependency.js

Statements: 14.29% (3 / 21)      Branches: 0% (0 / 6)      Functions: 0% (0 / 6)      Lines: 14.29% (3 / 21)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59          1                                                       1                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class HarmonyExportExpressionDependency extends NullDependency {
	constructor(originModule, range, rangeStatement) {
		super();
		this.originModule = originModule;
		this.range = range;
		this.rangeStatement = rangeStatement;
	}
 
	get type() {
		return "harmony export expression";
	}
 
	getExports() {
		return {
			exports: ["default"]
		};
	}
 
	describeHarmonyExport() {
		return {
			exportedName: "default",
			precedence: 1,
		};
	}
}
 
HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTemplate {
	apply(dep, source) {
		const used = dep.originModule.isUsed("default");
		const content = this.getContent(dep.originModule, used);
 
		if(dep.range) {
			source.replace(dep.rangeStatement[0], dep.range[0] - 1, content + "(");
			source.replace(dep.range[1], dep.rangeStatement[1] - 1, ");");
			return;
		}
 
		source.replace(dep.rangeStatement[0], dep.rangeStatement[1] - 1, content);
	}
 
	getContent(module, used) {
		const exportsName = module.exportsArgument || "exports";
		if(used) {
			return `/* harmony default export */ ${exportsName}[${JSON.stringify(used)}] = `;
		}
		return "/* unused harmony default export */ var _unused_webpack_default_export = ";
	}
};
 
module.exports = HarmonyExportExpressionDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportHeaderDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportHeaderDependency.js

Statements: 30% (3 / 10)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 30% (3 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30          1                           1               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class HarmonyExportHeaderDependency extends NullDependency {
	constructor(range, rangeStatement) {
		super();
		this.range = range;
		this.rangeStatement = rangeStatement;
	}
 
	get type() {
		return "harmony export header";
	}
}
 
HarmonyExportHeaderDependency.Template = class HarmonyExportDependencyTemplate {
	apply(dep, source) {
		const content = "";
		const replaceUntil = dep.range ? dep.range[0] - 1 : dep.rangeStatement[1] - 1;
		source.replace(dep.rangeStatement[0], replaceUntil, content);
	}
};
 
module.exports = HarmonyExportHeaderDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js

Statements: 2.94% (4 / 136)      Branches: 0% (0 / 108)      Functions: 0% (0 / 16)      Lines: 3.13% (4 / 128)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » HarmonyExportImportedSpecifierDependency.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288          1 1                                                                                                                                                                                                                                                                                                             1   1                                                                                                                                                                                                                                                                
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
 
class HarmonyExportImportedSpecifierDependency extends NullDependency {
	constructor(originModule, importDependency, importedVar, id, name) {
		super();
		this.originModule = originModule;
		this.importDependency = importDependency;
		this.importedVar = importedVar;
		this.id = id;
		this.name = name;
	}
 
	get type() {
		return "harmony export imported specifier";
	}
 
	getReference() {
		const name = this.name;
		const used = this.originModule.isUsed(name);
		const active = HarmonyModulesHelpers.isActive(this.originModule, this);
		const importedModule = this.importDependency.module;
 
		if(!importedModule || !used || !active) return null;
		if(!this.originModule.usedExports) return null;
 
		if(name) {
			const nameIsNotInUsedExports = Array.isArray(this.originModule.usedExports) && this.originModule.usedExports.indexOf(name) < 0;
			if(nameIsNotInUsedExports) return null;
 
			// export { name as name }
			if(this.id) {
				return {
					module: importedModule,
					importedNames: [this.id]
				};
			}
 
			// export { * as name }
			return {
				module: importedModule,
				importedNames: true
			};
		}
 
		// export *
		if(Array.isArray(this.originModule.usedExports)) {
			// reexport * with known used exports
			var activeExports = HarmonyModulesHelpers.getActiveExports(this.originModule, this);
			if(Array.isArray(importedModule.providedExports)) {
				return {
					module: importedModule,
					importedNames: this.originModule.usedExports.filter((id) => {
						const notInActiveExports = activeExports.indexOf(id) < 0;
						const notDefault = id !== "default";
						const inProvidedExports = importedModule.providedExports.indexOf(id) >= 0;
						return notInActiveExports && notDefault && inProvidedExports;
					}),
				};
			}
 
			return {
				module: importedModule,
				importedNames: this.originModule.usedExports.filter(id => {
					const notInActiveExports = activeExports.indexOf(id) < 0;
					const notDefault = id !== "default";
					return notInActiveExports && notDefault;
				}),
			};
		}
 
		if(Array.isArray(importedModule.providedExports)) {
			return {
				module: importedModule,
				importedNames: importedModule.providedExports.filter(id => id !== "default"),
			};
		}
 
		return {
			module: importedModule,
			importedNames: true,
		};
	}
 
	getExports() {
		if(this.name) {
			return {
				exports: [this.name]
			};
		}
 
		const importedModule = this.importDependency.module;
 
		if(!importedModule) {
			// no imported module available
			return {
				exports: null
			};
		}
 
		if(Array.isArray(importedModule.providedExports)) {
			return {
				exports: importedModule.providedExports.filter(id => id !== "default"),
				dependencies: [importedModule]
			};
		}
 
		if(importedModule.providedExports) {
			return {
				exports: true
			};
		}
 
		return {
			exports: null,
			dependencies: [importedModule]
		};
	}
 
	describeHarmonyExport() {
		const importedModule = this.importDependency.module;
		if(!this.name && importedModule && Array.isArray(importedModule.providedExports)) {
			// for a star export and when we know which exports are provided, we can tell so
			return {
				exportedName: importedModule.providedExports,
				precedence: 3
			};
		}
 
		return {
			exportedName: this.name,
			precedence: this.name ? 2 : 3
		};
	}
 
	updateHash(hash) {
		super.updateHash(hash);
		const hashValue = this.getHashValue(this.importDependency.module);
		hash.update(hashValue);
	}
 
	getHashValue(importedModule) {
		if(!importedModule) {
			return "";
		}
 
		const stringifiedUsedExport = JSON.stringify(importedModule.usedExports);
		const stringifiedProvidedExport = JSON.stringify(importedModule.providedExports);
		return importedModule.used + stringifiedUsedExport + stringifiedProvidedExport;
	}
}
 
module.exports = HarmonyExportImportedSpecifierDependency;
 
HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const content = this.getContent(dep);
		source.insert(-1, content);
	}
 
	getContent(dep) {
		const name = dep.importedVar;
		const used = dep.originModule.isUsed(dep.name);
		const importedModule = dep.importDependency.module;
		const active = HarmonyModulesHelpers.isActive(dep.originModule, dep);
		const importsExportsUnknown = !importedModule || !Array.isArray(importedModule.providedExports);
 
		const getReexportStatement = this.reexportStatementCreator(dep.originModule, importsExportsUnknown, name);
 
		// we want to rexport something, but the export isn't used
		if(!used) {
			return "/* unused harmony reexport " + dep.name + " */\n";
		}
 
		// we want to reexport something but another exports overrides this one
		if(!active) {
			return "/* inactive harmony reexport " + (dep.name || "namespace") + " */\n";
		}
 
		// we want to reexport the default export from a non-hamory module
		const isNotAHarmonyModule = !(importedModule && (!importedModule.meta || importedModule.meta.harmonyModule));
		if(dep.name && dep.id === "default" && isNotAHarmonyModule) {
			return "/* harmony reexport (default from non-hamory) */ " + getReexportStatement(JSON.stringify(used), null);
		}
 
		// we want to reexport a key as new key
		if(dep.name && dep.id) {
			var idUsed = importedModule && importedModule.isUsed(dep.id);
			return "/* harmony reexport (binding) */ " + getReexportStatement(JSON.stringify(used), JSON.stringify(idUsed));
		}
 
		// we want to reexport the module object as named export
		if(dep.name) {
			return "/* harmony reexport (module object) */ " + getReexportStatement(JSON.stringify(used), "");
		}
 
		// we know which exports are used
		if(Array.isArray(dep.originModule.usedExports)) {
			const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
			const items = dep.originModule.usedExports.map(function(id) {
				if(id === "default") return;
				if(activeExports.indexOf(id) >= 0) return;
				if(importedModule.isProvided(id) === false) return;
				var exportUsed = dep.originModule.isUsed(id);
				var idUsed = importedModule && importedModule.isUsed(id);
				return [exportUsed, idUsed];
			}).filter(Boolean);
 
			if(items.length === 0) {
				return "/* unused harmony namespace reexport */\n";
			}
 
			return items.map(function(item) {
				return "/* harmony namespace reexport (by used) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
			}).join("");
		}
 
		// not sure which exports are used, but we know which are provided
		if(dep.originModule.usedExports && importedModule && Array.isArray(importedModule.providedExports)) {
			const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
			const items = importedModule.providedExports.map(function(id) {
				if(id === "default") return;
				if(activeExports.indexOf(id) >= 0) return;
				var exportUsed = dep.originModule.isUsed(id);
				var idUsed = importedModule && importedModule.isUsed(id);
				return [exportUsed, idUsed];
			}).filter(Boolean);
 
			if(items.length === 0) {
				return "/* empty harmony namespace reexport */\n";
			}
 
			return items.map(function(item) {
				return "/* harmony namespace reexport (by provided) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
			}).join("");
		}
 
		// not sure which exports are used and provided
		if(dep.originModule.usedExports) {
			const activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule, dep);
			let content = "/* harmony namespace reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in " + name + ") ";
 
			// Filter out exports which are defined by other exports
			// and filter out default export because it cannot be reexported with *
			if(activeExports.length > 0)
				content += "if(" + JSON.stringify(activeExports.concat("default")) + ".indexOf(__WEBPACK_IMPORT_KEY__) < 0) ";
			else
				content += "if(__WEBPACK_IMPORT_KEY__ !== 'default') ";
			const exportsName = dep.originModule.exportsArgument || "exports";
			return content + `(function(key) { __webpack_require__.d(${exportsName}, key, function() { return ${name}[key]; }) }(__WEBPACK_IMPORT_KEY__));\n`;
		}
 
		return "/* unused harmony reexport namespace */\n";
	}
 
	reexportStatementCreator(module, importsExportsUnknown, name) {
		const exportsName = module.exportsArgument || "exports";
		const getReexportStatement = (key, valueKey) => {
			const conditional = this.getConditional(importsExportsUnknown, valueKey, name);
			const returnValue = this.getReturnValue(valueKey);
			return `${conditional}__webpack_require__.d(${exportsName}, ${key}, function() { return ${name}${returnValue}; });\n`;
		};
		return getReexportStatement;
	}
 
	getConditional(importsExportsUnknown, valueKey, name) {
		if(!importsExportsUnknown || !valueKey) {
			return "";
		}
 
		return `if(__webpack_require__.o(${name}, ${valueKey})) `;
	}
 
	getReturnValue(valueKey) {
		if(valueKey === null) {
			return "_default.a";
		}
 
		return valueKey && "[" + valueKey + "]";
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportSpecifierDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyExportSpecifierDependency.js

Statements: 15.38% (4 / 26)      Branches: 0% (0 / 14)      Functions: 0% (0 / 7)      Lines: 15.38% (4 / 26)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69          1 1                                                           1                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
 
class HarmonyExportSpecifierDependency extends NullDependency {
	constructor(originModule, id, name, position, immutable) {
		super();
		this.originModule = originModule;
		this.id = id;
		this.name = name;
		this.position = position;
		this.immutable = immutable;
	}
 
	get type() {
		return "harmony export specifier";
	}
 
	getExports() {
		return {
			exports: [this.name]
		};
	}
 
	describeHarmonyExport() {
		return {
			exportedName: this.name,
			precedence: 1
		};
	}
}
 
HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependencyTemplate {
	apply(dep, source) {
		const content = this.getPrefix(dep) + this.getContent(dep);
		source.insert(dep.position, content);
	}
 
	getPrefix(dep) {
		return dep.position > 0 ? "\n" : "";
	}
 
	getContent(dep) {
		const used = dep.originModule.isUsed(dep.name);
		const active = HarmonyModulesHelpers.isActive(dep.originModule, dep);
		if(!used) {
			return `/* unused harmony export ${(dep.name || "namespace")} */\n`;
		}
 
		if(!active) {
			return `/* inactive harmony export ${(dep.name || "namespace")} */\n`;
		}
 
		const exportsName = dep.originModule.exportsArgument || "exports";
		if(dep.immutable) {
			return `/* harmony export (immutable) */ ${exportsName}[${JSON.stringify(used)}] = ${dep.id};\n`;
		}
 
		return `/* harmony export (binding) */ __webpack_require__.d(${exportsName}, ${JSON.stringify(used)}, function() { return ${dep.id}; });\n`;
	}
};
 
module.exports = HarmonyExportSpecifierDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyImportDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyImportDependency.js

Statements: 17.65% (6 / 34)      Branches: 0% (0 / 19)      Functions: 0% (0 / 7)      Lines: 18.18% (6 / 33)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74          1                                                       1               1             1                                         1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
var ModuleDependency = require("./ModuleDependency");
 
class HarmonyImportDependency extends ModuleDependency {
	constructor(request, importedVar, range) {
		super(request);
		this.range = range;
		this.importedVar = importedVar;
	}
 
	get type() {
		return "harmony import";
	}
 
	getReference() {
		if(!this.module) return null;
 
		return {
			module: this.module,
			importedNames: false
		};
	}
 
	updateHash(hash) {
		super.updateHash(hash);
		hash.update((this.module && (!this.module.meta || this.module.meta.harmonyModule)) + "");
	}
}
 
HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const content = makeImportStatement(true, dep, outputOptions, requestShortener);
		source.replace(dep.range[0], dep.range[1] - 1, "");
		source.insert(-1, content);
	}
};
 
function getOptionalComment(pathinfo, shortenedRequest) {
	if(!pathinfo) {
		return "";
	}
	return `/*! ${shortenedRequest} */ `;
}
 
function makeImportStatement(declare, dep, outputOptions, requestShortener) {
	const comment = getOptionalComment(outputOptions.pathinfo, requestShortener.shorten(dep.request));
	const declaration = declare ? "var " : "";
	const newline = declare ? "\n" : " ";
 
	if(!dep.module) {
		const stringifiedError = JSON.stringify(`Cannot find module "${dep.request}"`);
		return `throw new Error(${stringifiedError});${newline}`;
	}
 
	if(dep.importedVar) {
		const isHarmonyModule = dep.module.meta && dep.module.meta.harmonyModule;
		const content = `/* harmony import */ ${declaration}${dep.importedVar} = __webpack_require__(${comment}${JSON.stringify(dep.module.id)});${newline}`;
		if(isHarmonyModule) {
			return content;
		}
		return `${content}/* harmony import */ ${declaration}${dep.importedVar}_default = __webpack_require__.n(${dep.importedVar});${newline}`;
	}
 
	return "";
}
HarmonyImportDependency.makeImportStatement = makeImportStatement;
 
module.exports = HarmonyImportDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js

Statements: 7.79% (6 / 77)      Branches: 0% (0 / 12)      Functions: 0% (0 / 2)      Lines: 7.89% (6 / 76)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » HarmonyImportDependencyParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104            1 1 1 1 1   1                                                                                                                                                                                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const HarmonyImportDependency = require("./HarmonyImportDependency");
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
const HarmonyModulesHelpers = require("./HarmonyModulesHelpers");
 
module.exports = class HarmonyImportDependencyParserPlugin {
	constructor(moduleOptions) {
		this.strictExportPresence = moduleOptions.strictExportPresence;
	}
 
	apply(parser) {
		parser.plugin("import", (statement, source) => {
			const dep = new HarmonyImportDependency(source, HarmonyModulesHelpers.getNewModuleVar(parser.state, source), statement.range);
			dep.loc = statement.loc;
			parser.state.current.addDependency(dep);
			parser.state.lastHarmonyImport = dep;
			return true;
		});
		parser.plugin("import specifier", (statement, source, id, name) => {
			parser.scope.definitions.length--;
			parser.scope.renames[`$${name}`] = "imported var";
			if(!parser.state.harmonySpecifier) parser.state.harmonySpecifier = {};
			parser.state.harmonySpecifier[`$${name}`] = [parser.state.lastHarmonyImport, HarmonyModulesHelpers.getModuleVar(parser.state, source), id];
			return true;
		});
		parser.plugin("expression imported var", (expr) => {
			const name = expr.name;
			const settings = parser.state.harmonySpecifier[`$${name}`];
			const dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], settings[2], name, expr.range, this.strictExportPresence);
			dep.shorthand = parser.scope.inShorthand;
			dep.directImport = true;
			dep.loc = expr.loc;
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("expression imported var.*", (expr) => {
			const name = expr.object.name;
			const settings = parser.state.harmonySpecifier[`$${name}`];
			if(settings[2] !== null)
				return false;
			const dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], expr.property.name || expr.property.value, name, expr.range, this.strictExportPresence);
			dep.shorthand = parser.scope.inShorthand;
			dep.directImport = false;
			dep.loc = expr.loc;
			parser.state.current.addDependency(dep);
			return true;
		});
		parser.plugin("call imported var", (expr) => {
			const args = expr.arguments;
			const fullExpr = expr;
			expr = expr.callee;
			const name = expr.name;
			const settings = parser.state.harmonySpecifier[`$${name}`];
			const dep = new HarmonyImportSpecifierDependency(settings[0], settings[1], settings[2], name, expr.range, this.strictExportPresence);
			dep.directImport = true;
			dep.callArgs = args;
			dep.call = fullExpr;
			dep.loc = expr.loc;
			parser.state.current.addDependency(dep);
			if(args)
				parser.walkExpressions(args);
			return true;
		});
		parser.plugin("hot accept callback", (expr, requests) => {
			const dependencies = requests
				.filter(request => HarmonyModulesHelpers.checkModuleVar(parser.state, request))
				.map(request => {
					const dep = new HarmonyAcceptImportDependency(request, HarmonyModulesHelpers.getModuleVar(parser.state, request), expr.range);
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
					return dep;
				});
			if(dependencies.length > 0) {
				const dep = new HarmonyAcceptDependency(expr.range, dependencies, true);
				dep.loc = expr.loc;
				parser.state.current.addDependency(dep);
			}
		});
		parser.plugin("hot accept without callback", (expr, requests) => {
			const dependencies = requests
				.filter(request => HarmonyModulesHelpers.checkModuleVar(parser.state, request))
				.map(request => {
					const dep = new HarmonyAcceptImportDependency(request, HarmonyModulesHelpers.getModuleVar(parser.state, request), expr.range);
					dep.loc = expr.loc;
					parser.state.current.addDependency(dep);
					return dep;
				});
			if(dependencies.length > 0) {
				const dep = new HarmonyAcceptDependency(expr.range, dependencies, false);
				dep.loc = expr.loc;
				parser.state.current.addDependency(dep);
			}
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js

Statements: 4.84% (3 / 62)      Branches: 0% (0 / 57)      Functions: 0% (0 / 11)      Lines: 4.92% (3 / 61)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127          1                                                                                                                                               1                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class HarmonyImportSpecifierDependency extends NullDependency {
	constructor(importDependency, importedVar, id, name, range, strictExportPresence) {
		super();
		this.importDependency = importDependency;
		this.importedVar = importedVar;
		this.id = id;
		this.name = name;
		this.range = range;
		this.strictExportPresence = strictExportPresence;
	}
 
	get type() {
		return "harmony import specifier";
	}
 
	getReference() {
		if(!this.importDependency.module) return null;
		return {
			module: this.importDependency.module,
			importedNames: this.id ? [this.id] : true
		};
	}
 
	getWarnings() {
		if(this.strictExportPresence) {
			return [];
		}
		return this._getErrors();
	}
 
	getErrors() {
		if(this.strictExportPresence) {
			return this._getErrors();
		}
		return [];
	}
 
	_getErrors() {
		const importedModule = this.importDependency.module;
		if(!importedModule || !importedModule.meta || !importedModule.meta.harmonyModule) {
			return;
		}
 
		if(!this.id) {
			return;
		}
 
		if(importedModule.isProvided(this.id) !== false) {
			return;
		}
 
		const idIsNotNameMessage = this.id !== this.name ? ` (imported as '${this.name}')` : "";
		const errorMessage = `"export '${this.id}'${idIsNotNameMessage} was not found in '${this.importDependency.userRequest}'`;
		const err = new Error(errorMessage);
		err.hideStack = true;
		return [err];
	}
 
	updateHash(hash) {
		super.updateHash(hash);
		const importedModule = this.importDependency.module;
		hash.update((importedModule && importedModule.id) + "");
		hash.update((importedModule && this.id) + "");
		hash.update((importedModule && this.importedVar) + "");
		hash.update((importedModule && this.id && importedModule.isUsed(this.id)) + "");
		hash.update((importedModule && (!importedModule.meta || importedModule.meta.harmonyModule)) + "");
		hash.update((importedModule && (importedModule.used + JSON.stringify(importedModule.usedExports))) + "");
	}
}
 
HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependencyTemplate {
	apply(dep, source) {
		const content = this.getContent(dep);
		source.replace(dep.range[0], dep.range[1] - 1, content);
	}
 
	getContent(dep) {
		const importedModule = dep.importDependency.module;
		const defaultImport = dep.directImport && dep.id === "default" && !(importedModule && (!importedModule.meta || importedModule.meta.harmonyModule));
		const shortHandPrefix = this.getShortHandPrefix(dep);
		const importedVar = dep.importedVar;
		const importedVarSuffix = this.getImportVarSuffix(dep, defaultImport, importedModule);
 
		if(dep.call && defaultImport) {
			return `${shortHandPrefix}${importedVar}_default()`;
		}
 
		if(dep.call && dep.id) {
			return `${shortHandPrefix}__webpack_require__.i(${importedVar}${importedVarSuffix})`;
		}
 
		return `${shortHandPrefix}${importedVar}${importedVarSuffix}`;
	}
 
	getImportVarSuffix(dep, defaultImport, importedModule) {
		if(defaultImport) {
			return "_default.a";
		}
 
		if(dep.id) {
			const used = importedModule ? importedModule.isUsed(dep.id) : dep.id;
			const optionalComment = dep.id !== used ? " /* " + dep.id + " */" : "";
			return `[${JSON.stringify(used)}${optionalComment}]`;
		}
 
		return "";
	}
 
	getShortHandPrefix(dep) {
		if(!dep.shorthand) {
			return "";
		}
 
		return dep.name + ": ";
	}
};
 
module.exports = HarmonyImportSpecifierDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyModulesHelpers.js

Statements: 2% (1 / 50)      Branches: 0% (0 / 48)      Functions: 0% (0 / 6)      Lines: 2.27% (1 / 44)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87                                                                                                                                                                        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class HarmonyModulesHelpers {
 
	static getModuleVar(state, request) {
		if(!state.harmonyModules) state.harmonyModules = [];
		var idx = state.harmonyModules.indexOf(request);
		if(idx < 0) {
			idx = state.harmonyModules.length;
			state.harmonyModules.push(request);
		}
		return "__WEBPACK_IMPORTED_MODULE_" + idx + "_" + request.replace(/[^A-Za-z0-9_]/g, "_").replace(/__+/g, "_") + "__";
	}
 
	static getNewModuleVar(state, request) {
		if(state.harmonyModules && state.harmonyModules.indexOf(request) >= 0)
			return null;
		return this.getModuleVar(state, request);
	}
 
	static checkModuleVar(state, request) {
		if(!state.harmonyModules || state.harmonyModules.indexOf(request) < 0)
			return null;
		return this.getModuleVar(state, request);
	}
 
	// checks if an harmony dependency is active in a module according to
	// precedence rules.
	static isActive(module, depInQuestion) {
		var desc = depInQuestion.describeHarmonyExport();
		if(!desc.exportedName) return true;
		var before = true;
		for(var i = 0; i < module.dependencies.length; i++) {
			var dep = module.dependencies[i];
			if(dep === depInQuestion) {
				before = false;
				continue;
			}
			if(!dep.describeHarmonyExport) continue;
			var d = dep.describeHarmonyExport();
			if(!d || !d.exportedName) continue;
			if(d.exportedName === desc.exportedName) {
				if(d.precedence < desc.precedence) {
					return false;
				}
				if(d.precedence === desc.precedence && !before) {
					return false;
				}
			}
		}
		return true;
	}
 
	// get a list of named exports defined in a module
	// doesn't include * reexports.
	static getActiveExports(module, currentDependency) {
		var desc = currentDependency && currentDependency.describeHarmonyExport();
		var currentIndex = currentDependency ? module.dependencies.indexOf(currentDependency) : -1;
		return module.dependencies.map((dep, idx) => {
			return {
				dep: dep,
				idx: idx
			};
		}).reduce((arr, data) => {
			var dep = data.dep;
			if(!dep.describeHarmonyExport) return arr;
			var d = dep.describeHarmonyExport();
			if(!d) return arr;
			if(!desc || (d.precedence < desc.precedence) || (d.precedence === desc.precedence && data.idx < currentIndex)) {
				var names = [].concat(d.exportedName);
				names.forEach(function(name) {
					if(name && arr.indexOf(name) < 0)
						arr.push(name);
				});
			}
			return arr;
		}, []);
	}
}
 
module.exports = HarmonyModulesHelpers;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyModulesPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/HarmonyModulesPlugin.js

Statements: 35.9% (14 / 39)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 35.9% (14 / 39)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74          1 1 1 1 1 1 1 1 1   1   1 1 1                                                                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const HarmonyImportDependency = require("./HarmonyImportDependency");
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
const HarmonyCompatiblilityDependency = require("./HarmonyCompatibilityDependency");
const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency");
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImportedSpecifierDependency");
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
 
const NullFactory = require("../NullFactory");
 
const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin");
const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin");
 
class HarmonyModulesPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(HarmonyImportDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(HarmonyImportDependency, new HarmonyImportDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyImportSpecifierDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyImportSpecifierDependency, new HarmonyImportSpecifierDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyCompatiblilityDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyCompatiblilityDependency, new HarmonyCompatiblilityDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyExportHeaderDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyExportHeaderDependency, new HarmonyExportHeaderDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyExportExpressionDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyExportExpressionDependency, new HarmonyExportExpressionDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyExportSpecifierDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyExportSpecifierDependency, new HarmonyExportSpecifierDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyExportImportedSpecifierDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyExportImportedSpecifierDependency, new HarmonyExportImportedSpecifierDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyAcceptDependency, new NullFactory());
			compilation.dependencyTemplates.set(HarmonyAcceptDependency, new HarmonyAcceptDependency.Template());
 
			compilation.dependencyFactories.set(HarmonyAcceptImportDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(HarmonyAcceptImportDependency, new HarmonyAcceptImportDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.harmony !== "undefined" && !parserOptions.harmony)
					return;
 
				parser.apply(
					new HarmonyDetectionParserPlugin(),
					new HarmonyImportDependencyParserPlugin(this.options),
					new HarmonyExportDependencyParserPlugin()
				);
			});
		});
	}
}
module.exports = HarmonyModulesPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportContextDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportContextDependency.js

Statements: 35.71% (5 / 14)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 35.71% (5 / 14)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38          1 1 1                                                   1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ContextDependency = require("./ContextDependency");
const CriticalDependencyWarning = require("./CriticalDependencyWarning");
const ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
 
class ImportContextDependency extends ContextDependency {
	constructor(request, recursive, regExp, range, valueRange, chunkName) {
		super(request, recursive, regExp);
		this.range = range;
		this.valueRange = valueRange;
		this.async = true;
		this.chunkName = chunkName;
	}
 
	get type() {
		return "import() context";
	}
 
	getWarnings() {
		if(!this.critical) {
			return;
		}
 
		return [
			new CriticalDependencyWarning(this.critical)
		];
	}
}
 
ImportContextDependency.Template = ContextDependencyTemplateAsRequireCall;
 
module.exports = ImportContextDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportDependenciesBlock.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportDependenciesBlock.js

Statements: 37.5% (3 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 37.5% (3 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19          1 1   1                    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
const ImportDependency = require("./ImportDependency");
 
module.exports = class ImportDependenciesBlock extends AsyncDependenciesBlock {
	constructor(request, range, chunkName, module, loc) {
		super(chunkName, module, loc);
		this.range = range;
		const dep = new ImportDependency(request, this);
		dep.loc = loc;
		this.addDependency(dep);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportDependency.js

Statements: 21.74% (5 / 23)      Branches: 0% (0 / 8)      Functions: 0% (0 / 5)      Lines: 21.74% (5 / 23)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56          1 1 1                         1                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const DepBlockHelpers = require("./DepBlockHelpers");
const webpackMissingPromiseModule = require("./WebpackMissingModule").promise;
 
class ImportDependency extends ModuleDependency {
	constructor(request, block) {
		super(request);
		this.block = block;
	}
 
	get type() {
		return "import()";
	}
}
 
ImportDependency.Template = class ImportDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const depBlock = dep.block;
		const promise = DepBlockHelpers.getDepBlockPromise(depBlock, outputOptions, requestShortener, "import()");
		const comment = this.getOptionalComment(outputOptions.pathinfo, requestShortener.shorten(dep.request));
 
		const content = this.getContent(promise, dep, comment);
		source.replace(depBlock.range[0], depBlock.range[1] - 1, content);
	}
 
	getOptionalComment(pathinfo, shortenedRequest) {
		if(!pathinfo) {
			return "";
		}
 
		return `/*! ${shortenedRequest} */ `;
	}
 
	getContent(promise, dep, comment) {
		if(promise && dep.module) {
			const stringifiedId = JSON.stringify(dep.module.id);
			return `${promise}.then(__webpack_require__.bind(null, ${comment}${stringifiedId}))`;
		}
 
		if(dep.module) {
			const stringifiedId = JSON.stringify(dep.module.id);
			return `Promise.resolve(__webpack_require__(${comment}${stringifiedId}))`;
		}
 
		return webpackMissingPromiseModule(dep.request);
	}
};
 
module.exports = ImportDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportParserPlugin.js

Statements: 14.29% (4 / 28)      Branches: 0% (0 / 12)      Functions: 0% (0 / 2)      Lines: 14.81% (4 / 27)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53            1 1 1                                                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ImportContextDependency = require("./ImportContextDependency");
const ImportDependenciesBlock = require("./ImportDependenciesBlock");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
 
class ImportParserPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(parser) {
		const options = this.options;
 
		parser.plugin(["call System.import", "import-call"], (expr) => {
			if(expr.arguments.length !== 1)
				throw new Error("Incorrect number of arguments provided to 'import(module: string) -> Promise'.");
 
			const param = parser.evaluateExpression(expr.arguments[0]);
 
			let chunkName = null;
 
			const importOptions = parser.getCommentOptions(expr.range);
			if(importOptions) {
				if(typeof importOptions.webpackChunkName !== "undefined") {
					if(typeof importOptions.webpackChunkName !== "string")
						throw new Error(`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`);
					chunkName = importOptions.webpackChunkName;
				}
			}
 
			if(param.isString()) {
				const depBlock = new ImportDependenciesBlock(param.string, expr.range, chunkName, parser.state.module, expr.loc);
				parser.state.current.addBlock(depBlock);
				return true;
			} else {
				const dep = ContextDependencyHelpers.create(ImportContextDependency, expr.range, param, expr, options, chunkName);
				if(!dep) return;
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
	}
}
module.exports = ImportParserPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ImportPlugin.js

Statements: 23.53% (4 / 17)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 23.53% (4 / 17)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42            1 1 1                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const ImportDependency = require("./ImportDependency");
const ImportContextDependency = require("./ImportContextDependency");
const ImportParserPlugin = require("./ImportParserPlugin");
 
class ImportPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
			const contextModuleFactory = params.contextModuleFactory;
 
			compilation.dependencyFactories.set(ImportDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(ImportDependency, new ImportDependency.Template());
 
			compilation.dependencyFactories.set(ImportContextDependency, contextModuleFactory);
			compilation.dependencyTemplates.set(ImportContextDependency, new ImportContextDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.import !== "undefined" && !parserOptions.import)
					return;
 
				parser.apply(
					new ImportParserPlugin(options)
				);
			});
		});
	}
}
module.exports = ImportPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LoaderDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LoaderDependency.js

Statements: 50% (2 / 4)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (2 / 4)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
 
class LoaderDependency extends ModuleDependency {
	constructor(request) {
		super(request);
	}
 
	get type() {
		return "loader";
	}
}
 
module.exports = LoaderDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LoaderPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LoaderPlugin.js

Statements: 7.5% (3 / 40)      Branches: 0% (0 / 18)      Functions: 0% (0 / 3)      Lines: 9.38% (3 / 32)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62            1                                               1                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const LoaderDependency = require("./LoaderDependency");
 
class LoaderPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(LoaderDependency, normalModuleFactory);
		});
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("normal-module-loader", (loaderContext, module) => {
				loaderContext.loadModule = function loadModule(request, callback) {
					const dep = new LoaderDependency(request);
					dep.loc = request;
					compilation.addModuleDependencies(module, [
						[dep]
					], true, "lm", false, (err) => {
						if(err) return callback(err);
 
						if(!dep.module) return callback(new Error("Cannot load the module"));
						if(dep.module.building) dep.module.building.push(next);
						else next();
 
						function next(err) {
							if(err) return callback(err);
 
							if(dep.module.error) return callback(dep.module.error);
							if(!dep.module._source) throw new Error("The module created for a LoaderDependency must have a property _source");
							let source, map;
							const moduleSource = dep.module._source;
							if(moduleSource.sourceAndMap) {
								const sourceAndMap = moduleSource.sourceAndMap();
								map = sourceAndMap.map;
								source = sourceAndMap.source;
							} else {
								map = moduleSource.map();
								source = moduleSource.source();
							}
							if(dep.module.fileDependencies) {
								dep.module.fileDependencies.forEach((dep) => loaderContext.addDependency(dep));
							}
							if(dep.module.contextDependencies) {
								dep.module.contextDependencies.forEach((dep) => loaderContext.addContextDependency(dep));
							}
							return callback(null, source, map, dep.module);
						}
					});
				};
			});
		});
	}
}
module.exports = LoaderPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LocalModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LocalModule.js

Statements: 14.29% (1 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 3)      Lines: 14.29% (1 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                            1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class LocalModule {
	constructor(module, name, idx) {
		this.module = module;
		this.name = name;
		this.idx = idx;
		this.used = false;
	}
 
	flagUsed() {
		this.used = true;
	}
 
	variableName() {
		return "__WEBPACK_LOCAL_MODULE_" + this.idx + "__";
	}
}
module.exports = LocalModule;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LocalModuleDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LocalModuleDependency.js

Statements: 30% (3 / 10)      Branches: 0% (0 / 2)      Functions: 0% (0 / 2)      Lines: 33.33% (3 / 9)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26          1                     1             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class LocalModuleDependency extends NullDependency {
	constructor(localModule, range) {
		super();
		localModule.flagUsed();
		this.localModule = localModule;
		this.range = range;
	}
}
 
LocalModuleDependency.Template = class LocalModuleDependencyTemplate {
	apply(dep, source) {
		if(!dep.range) return;
		source.replace(dep.range[0], dep.range[1] - 1, dep.localModule.variableName());
	}
};
 
module.exports = LocalModuleDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LocalModulesHelpers.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/LocalModulesHelpers.js

Statements: 20% (6 / 30)      Branches: 0% (0 / 14)      Functions: 100% (0 / 0)      Lines: 24% (6 / 25)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48            1 1   1                               1             1                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const LocalModule = require("./LocalModule");
const LocalModulesHelpers = exports;
 
const lookup = (parent, mod) => {
	if(mod.charAt(0) !== ".") return mod;
 
	var path = parent.split("/"),
		segs = mod.split("/");
	path.pop();
 
	for(var i = 0; i < segs.length; i++) {
		var seg = segs[i];
		if(seg === "..") path.pop();
		else if(seg !== ".") path.push(seg);
	}
 
	return path.join("/");
};
 
LocalModulesHelpers.addLocalModule = (state, name) => {
	if(!state.localModules) state.localModules = [];
	var m = new LocalModule(state.module, name, state.localModules.length);
	state.localModules.push(m);
	return m;
};
 
LocalModulesHelpers.getLocalModule = (state, name, namedModule) => {
	if(!state.localModules) return null;
	if(namedModule) {
		// resolve dependency name relative to the defining named module
		name = lookup(namedModule, name);
	}
	for(var i = 0; i < state.localModules.length; i++) {
		if(state.localModules[i].name === name)
			return state.localModules[i];
	}
	return null;
};
 
module.exports = LocalModulesHelpers;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleDependency.js

Statements: 25% (2 / 8)      Branches: 0% (0 / 2)      Functions: 0% (0 / 2)      Lines: 25% (2 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          1                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
 
class ModuleDependency extends Dependency {
	constructor(request) {
		super();
		this.request = request;
		this.userRequest = request;
	}
 
	isEqualResource(other) {
		if(!(other instanceof ModuleDependency))
			return false;
 
		return this.request === other.request;
	}
}
 
module.exports = ModuleDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleDependencyTemplateAsId.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleDependencyTemplateAsId.js

Statements: 11.11% (1 / 9)      Branches: 0% (0 / 6)      Functions: 0% (0 / 1)      Lines: 12.5% (1 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class ModuleDependencyTemplateAsId {
 
	apply(dep, source, outputOptions, requestShortener) {
		if(!dep.range) return;
		const comment = outputOptions.pathinfo ?
			`/*! ${requestShortener.shorten(dep.request)} */ ` : "";
		let content;
		if(dep.module)
			content = comment + JSON.stringify(dep.module.id);
		else
			content = require("./WebpackMissingModule").module(dep.request);
		source.replace(dep.range[0], dep.range[1] - 1, content);
	}
}
module.exports = ModuleDependencyTemplateAsId;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleDependencyTemplateAsRequireId.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleDependencyTemplateAsRequireId.js

Statements: 11.11% (1 / 9)      Branches: 0% (0 / 6)      Functions: 0% (0 / 1)      Lines: 12.5% (1 / 8)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » ModuleDependencyTemplateAsRequireId.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class ModuleDependencyTemplateAsRequireId {
 
	apply(dep, source, outputOptions, requestShortener) {
		if(!dep.range) return;
		const comment = outputOptions.pathinfo ?
			`/*! ${requestShortener.shorten(dep.request)} */ ` : "";
		let content;
		if(dep.module)
			content = `__webpack_require__(${comment}${JSON.stringify(dep.module.id)})`;
		else
			content = require("./WebpackMissingModule").module(dep.request);
		source.replace(dep.range[0], dep.range[1] - 1, content);
	}
}
module.exports = ModuleDependencyTemplateAsRequireId;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleHotAcceptDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleHotAcceptDependency.js

Statements: 50% (4 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (4 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          1 1                           1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const ModuleDependencyTemplateAsId = require("./ModuleDependencyTemplateAsId");
 
class ModuleHotAcceptDependency extends ModuleDependency {
	constructor(request, range) {
		super(request);
		this.range = range;
		this.weak = true;
	}
 
	get type() {
		return "module.hot.accept";
	}
}
 
ModuleHotAcceptDependency.Template = ModuleDependencyTemplateAsId;
 
module.exports = ModuleHotAcceptDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleHotDeclineDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/ModuleHotDeclineDependency.js

Statements: 50% (4 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (4 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          1 1                           1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const ModuleDependencyTemplateAsId = require("./ModuleDependencyTemplateAsId");
 
class ModuleHotDeclineDependency extends ModuleDependency {
	constructor(request, range) {
		super(request);
		this.range = range;
		this.weak = true;
	}
 
	get type() {
		return "module.hot.decline";
	}
}
 
ModuleHotDeclineDependency.Template = ModuleDependencyTemplateAsId;
 
module.exports = ModuleHotDeclineDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/MultiEntryDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/MultiEntryDependency.js

Statements: 33.33% (2 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22          1                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
 
class MultiEntryDependency extends Dependency {
	constructor(dependencies, name) {
		super();
		this.dependencies = dependencies;
		this.name = name;
	}
 
	get type() {
		return "multi entry";
	}
}
 
module.exports = MultiEntryDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/NullDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/NullDependency.js

Statements: 60% (3 / 5)      Branches: 100% (0 / 0)      Functions: 0% (0 / 4)      Lines: 60% (3 / 5)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26          1                           1       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const Dependency = require("../Dependency");
 
class NullDependency extends Dependency {
	get type() {
		return "null";
	}
 
	isEqualResource() {
		return false;
	}
 
	updateHash() {}
}
 
NullDependency.Template = class NullDependencyTemplate {
	apply() {}
};
 
module.exports = NullDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/PrefetchDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/PrefetchDependency.js

Statements: 50% (2 / 4)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (2 / 4)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
 
class PrefetchDependency extends ModuleDependency {
	constructor(request) {
		super(request);
	}
 
	get type() {
		return "prefetch";
	}
}
 
module.exports = PrefetchDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireContextDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireContextDependency.js

Statements: 57.14% (4 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 57.14% (4 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24          1 1                         1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ContextDependency = require("./ContextDependency");
const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateAsRequireId");
 
class RequireContextDependency extends ContextDependency {
	constructor(request, recursive, regExp, range) {
		super(request, recursive, regExp);
		this.range = range;
	}
 
	get type() {
		return "require.context";
	}
}
 
RequireContextDependency.Template = ModuleDependencyTemplateAsRequireId;
 
module.exports = RequireContextDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireContextDependencyParserPlugin.js

Statements: 9.09% (2 / 22)      Branches: 0% (0 / 9)      Functions: 0% (0 / 1)      Lines: 10.53% (2 / 19)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » RequireContextDependencyParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44            1   1                                                                      
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireContextDependency = require("./RequireContextDependency");
 
module.exports = class RequireContextDependencyParserPlugin {
	apply(parser) {
		parser.plugin("call require.context", expr => {
			let regExp = /^\.\/.*$/;
			let recursive = true;
			switch(expr.arguments.length) {
				case 3:
					{
						const regExpExpr = parser.evaluateExpression(expr.arguments[2]);
						if(!regExpExpr.isRegExp()) return;
						regExp = regExpExpr.regExp;
					}
					// falls through
				case 2:
					{
						const recursiveExpr = parser.evaluateExpression(expr.arguments[1]);
						if(!recursiveExpr.isBoolean()) return;
						recursive = recursiveExpr.bool;
					}
					// falls through
				case 1:
					{
						const requestExpr = parser.evaluateExpression(expr.arguments[0]);
						if(!requestExpr.isString()) return;
						const dep = new RequireContextDependency(requestExpr.string, recursive, regExp, expr.range);
						dep.loc = expr.loc;
						dep.optional = parser.scope.inTry;
						parser.state.current.addDependency(dep);
						return true;
					}
			}
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireContextPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireContextPlugin.js

Statements: 9.3% (4 / 43)      Branches: 0% (0 / 16)      Functions: 0% (0 / 2)      Lines: 9.76% (4 / 41)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79            1 1   1                                                                                                                                     1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireContextDependency = require("./RequireContextDependency");
const ContextElementDependency = require("./ContextElementDependency");
 
const RequireContextDependencyParserPlugin = require("./RequireContextDependencyParserPlugin");
 
class RequireContextPlugin {
	constructor(modulesDirectories, extensions) {
		if(!Array.isArray(modulesDirectories))
			throw new Error("modulesDirectories must be an array");
		if(!Array.isArray(extensions))
			throw new Error("extensions must be an array");
		this.modulesDirectories = modulesDirectories;
		this.extensions = extensions;
	}
 
	apply(compiler) {
		const modulesDirectories = this.modulesDirectories;
		const extensions = this.extensions;
		compiler.plugin("compilation", (compilation, params) => {
			const contextModuleFactory = params.contextModuleFactory;
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(RequireContextDependency, contextModuleFactory);
			compilation.dependencyTemplates.set(RequireContextDependency, new RequireContextDependency.Template());
 
			compilation.dependencyFactories.set(ContextElementDependency, normalModuleFactory);
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.requireContext !== "undefined" && !parserOptions.requireContext)
					return;
 
				parser.apply(new RequireContextDependencyParserPlugin());
			});
 
			params.contextModuleFactory.plugin("alternatives", (items, callback) => {
				if(items.length === 0) return callback(null, items);
 
				callback(null, items.map((obj) => {
					return extensions.filter((ext) => {
						const l = obj.request.length;
						return l > ext.length && obj.request.substr(l - ext.length, l) === ext;
					}).map((ext) => {
						const l = obj.request.length;
						return {
							context: obj.context,
							request: obj.request.substr(0, l - ext.length)
						};
					}).concat(obj);
				}).reduce((a, b) => a.concat(b), []));
			});
 
			params.contextModuleFactory.plugin("alternatives", (items, callback) => {
				if(items.length === 0) return callback(null, items);
 
				callback(null, items.map((obj) => {
					for(let i = 0; i < modulesDirectories.length; i++) {
						const dir = modulesDirectories[i];
						const idx = obj.request.indexOf("./" + dir + "/");
						if(idx === 0) {
							obj.request = obj.request.slice(dir.length + 3);
							break;
						}
					}
					return obj;
				}));
			});
		});
	}
}
module.exports = RequireContextPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js

Statements: 18.75% (3 / 16)      Branches: 0% (0 / 10)      Functions: 0% (0 / 1)      Lines: 18.75% (3 / 16)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30          1 1   1                                          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
const RequireEnsureDependency = require("./RequireEnsureDependency");
 
module.exports = class RequireEnsureDependenciesBlock extends AsyncDependenciesBlock {
	constructor(expr, successExpression, errorExpression, chunkName, chunkNameRange, module, loc) {
		super(chunkName, module, loc);
		this.expr = expr;
		const successBodyRange = successExpression && successExpression.body && successExpression.body.range;
		const errorBodyRange = errorExpression && errorExpression.body && errorExpression.body.range;
		this.range = null;
		if(successBodyRange) {
			if(errorBodyRange) {
				this.range = [successBodyRange[0] + 1, errorBodyRange[1] - 1];
			} else {
				this.range = [successBodyRange[0] + 1, successBodyRange[1] - 1];
			}
		}
		this.chunkNameRange = chunkNameRange;
		const dep = new RequireEnsureDependency(this);
		dep.loc = loc;
		this.addDependency(dep);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js

Statements: 6.67% (4 / 60)      Branches: 0% (0 / 37)      Functions: 0% (0 / 1)      Lines: 6.9% (4 / 58)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » RequireEnsureDependenciesBlockParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104            1 1 1   1                                                                                                                                                                                          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireEnsureDependenciesBlock = require("./RequireEnsureDependenciesBlock");
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
const getFunctionExpression = require("./getFunctionExpression");
 
module.exports = class RequireEnsureDependenciesBlockParserPlugin {
	apply(parser) {
		parser.plugin("call require.ensure", expr => {
			let chunkName = null;
			let chunkNameRange = null;
			let errorExpressionArg = null;
			let errorExpression = null;
			switch(expr.arguments.length) {
				case 4:
					{
						const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
						if(!chunkNameExpr.isString()) return;
						chunkNameRange = chunkNameExpr.range;
						chunkName = chunkNameExpr.string;
					}
					// falls through
				case 3:
					{
						errorExpressionArg = expr.arguments[2];
						errorExpression = getFunctionExpression(errorExpressionArg);
 
						if(!errorExpression && !chunkName) {
							const chunkNameExpr = parser.evaluateExpression(expr.arguments[2]);
							if(!chunkNameExpr.isString()) return;
							chunkNameRange = chunkNameExpr.range;
							chunkName = chunkNameExpr.string;
						}
					}
					// falls through
				case 2:
					{
						const dependenciesExpr = parser.evaluateExpression(expr.arguments[0]);
						const dependenciesItems = dependenciesExpr.isArray() ? dependenciesExpr.items : [dependenciesExpr];
						const successExpressionArg = expr.arguments[1];
						const successExpression = getFunctionExpression(successExpressionArg);
 
						if(successExpression) {
							parser.walkExpressions(successExpression.expressions);
						}
						if(errorExpression) {
							parser.walkExpressions(errorExpression.expressions);
						}
 
						const dep = new RequireEnsureDependenciesBlock(expr,
							successExpression ? successExpression.fn : successExpressionArg,
							errorExpression ? errorExpression.fn : errorExpressionArg,
							chunkName, chunkNameRange, parser.state.module, expr.loc);
						const old = parser.state.current;
						parser.state.current = dep;
						try {
							let failed = false;
							parser.inScope([], () => {
								dependenciesItems.forEach(ee => {
									if(ee.isString()) {
										const edep = new RequireEnsureItemDependency(ee.string, ee.range);
										edep.loc = dep.loc;
										dep.addDependency(edep);
									} else {
										failed = true;
									}
								});
							});
							if(failed) {
								return;
							}
							if(successExpression) {
								if(successExpression.fn.body.type === "BlockStatement")
									parser.walkStatement(successExpression.fn.body);
								else
									parser.walkExpression(successExpression.fn.body);
							}
							old.addBlock(dep);
						} finally {
							parser.state.current = old;
						}
						if(!successExpression) {
							parser.walkExpression(successExpressionArg);
						}
						if(errorExpression) {
							if(errorExpression.fn.body.type === "BlockStatement")
								parser.walkStatement(errorExpression.fn.body);
							else
								parser.walkExpression(errorExpression.fn.body);
						} else if(errorExpressionArg) {
							parser.walkExpression(errorExpressionArg);
						}
						return true;
					}
			}
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureDependency.js

Statements: 22.22% (4 / 18)      Branches: 0% (0 / 5)      Functions: 0% (0 / 3)      Lines: 22.22% (4 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40          1 1                         1                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
const DepBlockHelpers = require("./DepBlockHelpers");
 
class RequireEnsureDependency extends NullDependency {
	constructor(block) {
		super();
		this.block = block;
	}
 
	get type() {
		return "require.ensure";
	}
}
 
RequireEnsureDependency.Template = class RequireEnsureDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const depBlock = dep.block;
		const wrapper = DepBlockHelpers.getLoadDepBlockWrapper(depBlock, outputOptions, requestShortener, "require.ensure");
		const errorCallbackExists = depBlock.expr.arguments.length === 4 || (!depBlock.chunkName && depBlock.expr.arguments.length === 3);
		const startBlock = wrapper[0] + "(";
		const middleBlock = `).bind(null, __webpack_require__)${wrapper[1]}`;
		const endBlock = `${middleBlock}__webpack_require__.oe${wrapper[2]}`;
		source.replace(depBlock.expr.range[0], depBlock.expr.arguments[1].range[0] - 1, startBlock);
		if(errorCallbackExists) {
			source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.arguments[2].range[0] - 1, middleBlock);
			source.replace(depBlock.expr.arguments[2].range[1], depBlock.expr.range[1] - 1, wrapper[2]);
		} else {
			source.replace(depBlock.expr.arguments[1].range[1], depBlock.expr.range[1] - 1, endBlock);
		}
	}
};
 
module.exports = RequireEnsureDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureItemDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsureItemDependency.js

Statements: 66.67% (4 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 66.67% (4 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23          1 1                       1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const NullDependency = require("./NullDependency");
 
class RequireEnsureItemDependency extends ModuleDependency {
	constructor(request) {
		super(request);
	}
 
	get type() {
		return "require.ensure item";
	}
}
 
RequireEnsureItemDependency.Template = NullDependency.Template;
 
module.exports = RequireEnsureItemDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsurePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireEnsurePlugin.js

Statements: 33.33% (6 / 18)      Branches: 0% (0 / 4)      Functions: 0% (0 / 1)      Lines: 33.33% (6 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42            1 1   1   1   1                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
const RequireEnsureDependency = require("./RequireEnsureDependency");
 
const NullFactory = require("../NullFactory");
 
const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
 
const ParserHelpers = require("../ParserHelpers");
 
class RequireEnsurePlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(RequireEnsureItemDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(RequireEnsureItemDependency, new RequireEnsureItemDependency.Template());
 
			compilation.dependencyFactories.set(RequireEnsureDependency, new NullFactory());
			compilation.dependencyTemplates.set(RequireEnsureDependency, new RequireEnsureDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.requireEnsure !== "undefined" && !parserOptions.requireEnsure)
					return;
 
				parser.apply(new RequireEnsureDependenciesBlockParserPlugin());
				parser.plugin("evaluate typeof require.ensure", ParserHelpers.evaluateToString("function"));
				parser.plugin("typeof require.ensure", ParserHelpers.toConstantDependency(JSON.stringify("function")));
			});
		});
	}
}
module.exports = RequireEnsurePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireHeaderDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireHeaderDependency.js

Statements: 33.33% (3 / 9)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 37.5% (3 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          1                   1                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class RequireHeaderDependency extends NullDependency {
	constructor(range) {
		super();
		if(!Array.isArray(range)) throw new Error("range must be valid");
		this.range = range;
	}
}
 
RequireHeaderDependency.Template = class RequireHeaderDependencyTemplate {
	apply(dep, source) {
		source.replace(dep.range[0], dep.range[1] - 1, "__webpack_require__");
	}
 
	applyAsTemplateArgument(name, dep, source) {
		source.replace(dep.range[0], dep.range[1] - 1, "require");
	}
};
 
module.exports = RequireHeaderDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireIncludeDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireIncludeDependency.js

Statements: 27.27% (3 / 11)      Branches: 0% (0 / 4)      Functions: 0% (0 / 4)      Lines: 27.27% (3 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35          1                         1                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
 
class RequireIncludeDependency extends ModuleDependency {
	constructor(request, range) {
		super(request);
		this.range = range;
	}
 
	get type() {
		return "require.include";
	}
}
 
RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		const comment = this.getOptionalComment(outputOptions.pathinfo && dep.module, requestShortener.shorten(dep.request));
		source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
	}
 
	getOptionalComment(shouldHaveComment, shortenedRequest) {
		if(shouldHaveComment) {
			return "";
		}
		return `/*! require.include ${shortenedRequest} */`;
	}
};
 
module.exports = RequireIncludeDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireIncludeDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireIncludeDependencyParserPlugin.js

Statements: 16.67% (2 / 12)      Branches: 0% (0 / 4)      Functions: 0% (0 / 1)      Lines: 20% (2 / 10)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » RequireIncludeDependencyParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23            1   1                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireIncludeDependency = require("./RequireIncludeDependency");
 
module.exports = class RequireIncludeDependencyParserPlugin {
	apply(parser) {
		parser.plugin("call require.include", expr => {
			if(expr.arguments.length !== 1) return;
			const param = parser.evaluateExpression(expr.arguments[0]);
			if(!param.isString()) return;
			const dep = new RequireIncludeDependency(param.string, expr.range);
			dep.loc = expr.loc;
			parser.state.current.addDependency(dep);
			return true;
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireIncludePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireIncludePlugin.js

Statements: 28.57% (4 / 14)      Branches: 0% (0 / 4)      Functions: 0% (0 / 1)      Lines: 28.57% (4 / 14)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35            1 1   1                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireIncludeDependency = require("./RequireIncludeDependency");
const RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin");
 
const ParserHelpers = require("../ParserHelpers");
 
class RequireIncludePlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			const normalModuleFactory = params.normalModuleFactory;
 
			compilation.dependencyFactories.set(RequireIncludeDependency, normalModuleFactory);
			compilation.dependencyTemplates.set(RequireIncludeDependency, new RequireIncludeDependency.Template());
 
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.requireInclude !== "undefined" && !parserOptions.requireInclude)
					return;
 
				parser.apply(new RequireIncludeDependencyParserPlugin());
				parser.plugin("evaluate typeof require.include", ParserHelpers.evaluateToString("function"));
				parser.plugin("typeof require.include", ParserHelpers.toConstantDependency(JSON.stringify("function")));
			});
		});
	}
}
module.exports = RequireIncludePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveContextDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveContextDependency.js

Statements: 41.67% (5 / 12)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 41.67% (5 / 12)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36          1 1 1                                               1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ContextDependency = require("./ContextDependency");
const CriticalDependencyWarning = require("./CriticalDependencyWarning");
const ContextDependencyTemplateAsId = require("./ContextDependencyTemplateAsId");
 
class RequireResolveContextDependency extends ContextDependency {
	constructor(request, recursive, regExp, range, valueRange) {
		super(request, recursive, regExp);
		this.range = range;
		this.valueRange = valueRange;
	}
 
	get type() {
		return "amd require context";
	}
 
	getWarnings() {
		if(!this.critical) {
			return;
		}
 
		return [
			new CriticalDependencyWarning(this.critical)
		];
	}
}
 
RequireResolveContextDependency.Template = ContextDependencyTemplateAsId;
 
module.exports = RequireResolveContextDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveDependency.js

Statements: 57.14% (4 / 7)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 57.14% (4 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24          1 1                         1   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
const ModuleDependencyAsId = require("./ModuleDependencyTemplateAsId");
 
class RequireResolveDependency extends ModuleDependency {
	constructor(request, range) {
		super(request);
		this.range = range;
	}
 
	get type() {
		return "require.resolve";
	}
}
 
RequireResolveDependency.Template = ModuleDependencyAsId;
 
module.exports = RequireResolveDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveDependencyParserPlugin.js

Statements: 10.42% (5 / 48)      Branches: 0% (0 / 12)      Functions: 0% (0 / 2)      Lines: 10.87% (5 / 46)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/dependencies/ » RequireResolveDependencyParserPlugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73            1 1 1 1                                                                                                                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const RequireResolveDependency = require("./RequireResolveDependency");
const RequireResolveContextDependency = require("./RequireResolveContextDependency");
const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
 
class RequireResolveDependencyParserPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(parser) {
		const options = this.options;
		parser.plugin("call require.resolve", (expr) => {
			return parser.applyPluginsBailResult("call require.resolve(Weak)", expr, false);
		});
		parser.plugin("call require.resolveWeak", (expr) => {
			return parser.applyPluginsBailResult("call require.resolve(Weak)", expr, true);
		});
		parser.plugin("call require.resolve(Weak)", (expr, weak) => {
			if(expr.arguments.length !== 1) return;
			const param = parser.evaluateExpression(expr.arguments[0]);
			if(param.isConditional()) {
				param.options.forEach((option) => {
					const result = parser.applyPluginsBailResult("call require.resolve(Weak):item", expr, option, weak);
					if(result === undefined) {
						parser.applyPluginsBailResult("call require.resolve(Weak):context", expr, option, weak);
					}
				});
				const dep = new RequireResolveHeaderDependency(expr.callee.range);
				dep.loc = expr.loc;
				parser.state.current.addDependency(dep);
				return true;
			} else {
				const result = parser.applyPluginsBailResult("call require.resolve(Weak):item", expr, param, weak);
				if(result === undefined) {
					parser.applyPluginsBailResult("call require.resolve(Weak):context", expr, param, weak);
				}
				const dep = new RequireResolveHeaderDependency(expr.callee.range);
				dep.loc = expr.loc;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call require.resolve(Weak):item", (expr, param, weak) => {
			if(param.isString()) {
				const dep = new RequireResolveDependency(param.string, param.range);
				dep.loc = expr.loc;
				dep.optional = !!parser.scope.inTry;
				dep.weak = weak;
				parser.state.current.addDependency(dep);
				return true;
			}
		});
		parser.plugin("call require.resolve(Weak):context", (expr, param, weak) => {
			const dep = ContextDependencyHelpers.create(RequireResolveContextDependency, param.range, param, expr, options);
			if(!dep) return;
			dep.loc = expr.loc;
			dep.optional = !!parser.scope.inTry;
			dep.weak = weak;
			parser.state.current.addDependency(dep);
			return true;
		});
	}
}
module.exports = RequireResolveDependencyParserPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveHeaderDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/RequireResolveHeaderDependency.js

Statements: 33.33% (3 / 9)      Branches: 0% (0 / 2)      Functions: 0% (0 / 3)      Lines: 37.5% (3 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28          1                   1                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
 
class RequireResolveHeaderDependency extends NullDependency {
	constructor(range) {
		super();
		if(!Array.isArray(range)) throw new Error("range must be valid");
		this.range = range;
	}
}
 
RequireResolveHeaderDependency.Template = class RequireResolveHeaderDependencyTemplate {
	apply(dep, source) {
		source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
	}
 
	applyAsTemplateArgument(name, dep, source) {
		source.replace(dep.range[0], dep.range[1] - 1, "/*require.resolve*/");
	}
};
 
module.exports = RequireResolveHeaderDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/SingleEntryDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/SingleEntryDependency.js

Statements: 50% (2 / 4)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (2 / 4)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          1                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ModuleDependency = require("./ModuleDependency");
 
class SingleEntryDependency extends ModuleDependency {
	constructor(request) {
		super(request);
	}
 
	get type() {
		return "single entry";
	}
}
 
module.exports = SingleEntryDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/SystemPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/SystemPlugin.js

Statements: 15% (3 / 20)      Branches: 0% (0 / 4)      Functions: 0% (0 / 4)      Lines: 15% (3 / 20)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46          1                           1                                               1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const ParserHelpers = require("../ParserHelpers");
 
class SystemPlugin {
	constructor(options) {
		this.options = options;
	}
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation, params) => {
			params.normalModuleFactory.plugin("parser", (parser, parserOptions) => {
 
				if(typeof parserOptions.system !== "undefined" && !parserOptions.system)
					return;
 
				function setNotSupported(name) {
					parser.plugin("evaluate typeof " + name, ParserHelpers.evaluateToString("undefined"));
					parser.plugin("expression " + name,
						ParserHelpers.expressionIsUnsupported(name + " is not supported by webpack.")
					);
				}
 
				parser.plugin("typeof System.import", ParserHelpers.toConstantDependency(JSON.stringify("function")));
				parser.plugin("evaluate typeof System.import", ParserHelpers.evaluateToString("function"));
				parser.plugin("typeof System", ParserHelpers.toConstantDependency(JSON.stringify("object")));
				parser.plugin("evaluate typeof System", ParserHelpers.evaluateToString("object"));
 
				setNotSupported("System.set");
				setNotSupported("System.get");
				setNotSupported("System.register");
				parser.plugin("expression System", function() {
					const systemPolyfillRequire = ParserHelpers.requireFileAsExpression(
						this.state.module.context, require.resolve("../../buildin/system.js"));
					return ParserHelpers.addParsedVariableToModule(this, "System", systemPolyfillRequire);
				});
			});
		});
	}
}
module.exports = SystemPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/UnsupportedDependency.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/UnsupportedDependency.js

Statements: 50% (4 / 8)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 50% (4 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          1 1                   1           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const NullDependency = require("./NullDependency");
const webpackMissingModule = require("./WebpackMissingModule").module;
 
class UnsupportedDependency extends NullDependency {
	constructor(request, range) {
		super();
		this.request = request;
		this.range = range;
	}
}
 
UnsupportedDependency.Template = class UnsupportedDependencyTemplate {
	apply(dep, source, outputOptions, requestShortener) {
		source.replace(dep.range[0], dep.range[1], webpackMissingModule(dep.request));
	}
};
 
module.exports = UnsupportedDependency;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/WebpackMissingModule.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/WebpackMissingModule.js

Statements: 40% (4 / 10)      Branches: 100% (0 / 0)      Functions: 100% (0 / 0)      Lines: 50% (4 / 8)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20          1   1   1         1          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
const toErrorCode = err => `var e = new Error(${JSON.stringify(err)}); e.code = 'MODULE_NOT_FOUND';`;
 
exports.module = request => `!(function webpackMissingModule() { ${exports.moduleCode(request)} }())`;
 
exports.promise = (request) => {
	const errorCode = toErrorCode(`Cannot find module "${request}"`);
	return `Promise.reject(function webpackMissingModule() { ${errorCode}; return e; }())`;
};
 
exports.moduleCode = (request) => {
	const errorCode = toErrorCode(`Cannot find module "${request}"`);
	return `${errorCode} throw e;`;
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/getFunctionExpression.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/dependencies/getFunctionExpression.js

Statements: 14.29% (1 / 7)      Branches: 0% (0 / 24)      Functions: 0% (0 / 1)      Lines: 14.29% (1 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46        1                                                                                  
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
module.exports = function(expr) {
	// <FunctionExpression>
	if(expr.type === "FunctionExpression" || expr.type === "ArrowFunctionExpression") {
		return {
			fn: expr,
			expressions: [],
			needThis: false
		};
	}
 
	// <FunctionExpression>.bind(<Expression>)
	if(expr.type === "CallExpression" &&
		expr.callee.type === "MemberExpression" &&
		expr.callee.object.type === "FunctionExpression" &&
		expr.callee.property.type === "Identifier" &&
		expr.callee.property.name === "bind" &&
		expr.arguments.length === 1) {
		return {
			fn: expr.callee.object,
			expressions: [expr.arguments[0]]
		};
	}
	// (function(_this) {return <FunctionExpression>})(this) (Coffeescript)
	if(expr.type === "CallExpression" &&
		expr.callee.type === "FunctionExpression" &&
		expr.callee.body.type === "BlockStatement" &&
		expr.arguments.length === 1 &&
		expr.arguments[0].type === "ThisExpression" &&
		expr.callee.body.body &&
		expr.callee.body.body.length === 1 &&
		expr.callee.body.body[0].type === "ReturnStatement" &&
		expr.callee.body.body[0].argument &&
		expr.callee.body.body[0].argument.type === "FunctionExpression") {
		return {
			fn: expr.callee.body.body[0].argument,
			expressions: [],
			needThis: true
		};
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/

Statements: 17.19% (11 / 64)      Branches: 0% (0 / 32)      Functions: 0% (0 / 4)      Lines: 17.19% (11 / 64)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/node/
File Statements Branches Functions Lines
NodeEnvironmentPlugin.js 38.46% (5 / 13) 0% (0 / 2) 0% (0 / 1) 38.46% (5 / 13)
NodeOutputFileSystem.js 40% (4 / 10) 100% (0 / 0) 0% (0 / 1) 40% (4 / 10)
NodeWatchFileSystem.js 4.88% (2 / 41) 0% (0 / 30) 0% (0 / 2) 4.88% (2 / 41)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/NodeEnvironmentPlugin.js

Statements: 38.46% (5 / 13)      Branches: 0% (0 / 2)      Functions: 0% (0 / 1)      Lines: 38.46% (5 / 13)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27            1 1 1 1                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const NodeWatchFileSystem = require("./NodeWatchFileSystem");
const NodeOutputFileSystem = require("./NodeOutputFileSystem");
const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem");
const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem");
 
class NodeEnvironmentPlugin {
	apply(compiler) {
		compiler.inputFileSystem = new CachedInputFileSystem(new NodeJsInputFileSystem(), 60000);
		const inputFileSystem = compiler.inputFileSystem;
		compiler.outputFileSystem = new NodeOutputFileSystem();
		compiler.watchFileSystem = new NodeWatchFileSystem(compiler.inputFileSystem);
		compiler.plugin("before-run", (compiler, callback) => {
			if(compiler.inputFileSystem === inputFileSystem)
				inputFileSystem.purge();
			callback();
		});
	}
}
module.exports = NodeEnvironmentPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/NodeOutputFileSystem.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/NodeOutputFileSystem.js

Statements: 40% (4 / 10)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 40% (4 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24            1 1 1                         1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const fs = require("fs");
const path = require("path");
const mkdirp = require("mkdirp");
 
class NodeOutputFileSystem {
	constructor() {
		this.mkdirp = mkdirp;
		this.mkdir = fs.mkdir.bind(fs);
		this.rmdir = fs.rmdir.bind(fs);
		this.unlink = fs.unlink.bind(fs);
		this.writeFile = fs.writeFile.bind(fs);
		this.join = path.join.bind(path);
	}
}
 
module.exports = NodeOutputFileSystem;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/NodeWatchFileSystem.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/node/NodeWatchFileSystem.js

Statements: 4.88% (2 / 41)      Branches: 0% (0 / 30)      Functions: 0% (0 / 2)      Lines: 4.88% (2 / 41)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74            1                                                                                                                                 1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const Watchpack = require("watchpack");
 
class NodeWatchFileSystem {
	constructor(inputFileSystem) {
		this.inputFileSystem = inputFileSystem;
		this.watcherOptions = {
			aggregateTimeout: 0
		};
		this.watcher = new Watchpack(this.watcherOptions);
	}
 
	watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
		if(!Array.isArray(files))
			throw new Error("Invalid arguments: 'files'");
		if(!Array.isArray(dirs))
			throw new Error("Invalid arguments: 'dirs'");
		if(!Array.isArray(missing))
			throw new Error("Invalid arguments: 'missing'");
		if(typeof callback !== "function")
			throw new Error("Invalid arguments: 'callback'");
		if(typeof startTime !== "number" && startTime)
			throw new Error("Invalid arguments: 'startTime'");
		if(typeof options !== "object")
			throw new Error("Invalid arguments: 'options'");
		if(typeof callbackUndelayed !== "function" && callbackUndelayed)
			throw new Error("Invalid arguments: 'callbackUndelayed'");
		const oldWatcher = this.watcher;
		this.watcher = new Watchpack(options);
 
		if(callbackUndelayed)
			this.watcher.once("change", callbackUndelayed);
 
		this.watcher.once("aggregated", (changes, removals) => {
			changes = changes.concat(removals);
			if(this.inputFileSystem && this.inputFileSystem.purge) {
				this.inputFileSystem.purge(changes);
			}
			const times = this.watcher.getTimes();
			callback(null,
				changes.filter(file => files.indexOf(file) >= 0).sort(),
				changes.filter(file => dirs.indexOf(file) >= 0).sort(),
				changes.filter(file => missing.indexOf(file) >= 0).sort(), times, times);
		});
 
		this.watcher.watch(files.concat(missing), dirs, startTime);
 
		if(oldWatcher) {
			oldWatcher.close();
		}
		return {
			close: () => {
				if(this.watcher) {
					this.watcher.close();
					this.watcher = null;
				}
			},
			pause: () => {
				if(this.watcher) {
					this.watcher.pause();
				}
			}
		};
	}
}
 
module.exports = NodeWatchFileSystem;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/

Statements: 4.93% (39 / 791)      Branches: 0% (0 / 439)      Functions: 0% (0 / 54)      Lines: 5.42% (39 / 720)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/optimize/
File Statements Branches Functions Lines
AggressiveMergingPlugin.js 2.94% (2 / 68) 0% (0 / 29) 0% (0 / 3) 3.13% (2 / 64)
AggressiveSplittingPlugin.js 5.38% (7 / 130) 0% (0 / 86) 0% (0 / 11) 5.88% (7 / 119)
ChunkModuleIdRangePlugin.js 3.45% (1 / 29) 0% (0 / 13) 0% (0 / 2) 3.57% (1 / 28)
CommonsChunkPlugin.js 1.44% (2 / 139) 0% (0 / 78) 0% (0 / 14) 1.48% (2 / 135)
DedupePlugin.js 33.33% (1 / 3) 100% (0 / 0) 0% (0 / 1) 33.33% (1 / 3)
EnsureChunkConditionsPlugin.js 5% (1 / 20) 0% (0 / 10) 0% (0 / 1) 5.56% (1 / 18)
FlagIncludedChunksPlugin.js 6.67% (1 / 15) 0% (0 / 8) 0% (0 / 1) 9.09% (1 / 11)
LimitChunkCountPlugin.js 3.03% (1 / 33) 0% (0 / 21) 0% (0 / 2) 3.45% (1 / 29)
MergeDuplicateChunksPlugin.js 12.5% (2 / 16) 0% (0 / 8) 0% (0 / 2) 13.33% (2 / 15)
MinChunkSizePlugin.js 3.13% (1 / 32) 0% (0 / 10) 0% (0 / 2) 3.33% (1 / 30)
OccurrenceOrderPlugin.js 6.38% (6 / 94) 0% (0 / 52) 0% (0 / 7) 8.22% (6 / 73)
RemoveEmptyChunksPlugin.js 14.29% (1 / 7) 0% (0 / 3) 0% (0 / 1) 16.67% (1 / 6)
RemoveParentModulesPlugin.js 9.09% (5 / 55) 0% (0 / 24) 0% (0 / 5) 10% (5 / 50)
UglifyJsPlugin.js 5.33% (8 / 150) 0% (0 / 97) 0% (0 / 2) 5.76% (8 / 139)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/AggressiveMergingPlugin.js

Statements: 2.94% (2 / 68)      Branches: 0% (0 / 29)      Functions: 0% (0 / 3)      Lines: 3.13% (2 / 64)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123                                    1                                                                                                                                                                                                           1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class AggressiveMergingPlugin {
	constructor(options) {
		if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
			throw new Error("Argument should be an options object. To use defaults, pass in nothing.\nFor more info on options, see https://webpack.js.org/plugins/");
		}
		this.options = options || {};
	}
 
	apply(compiler) {
		const options = this.options;
		const minSizeReduce = options.minSizeReduce || 1.5;
 
		function getParentsWeight(chunk) {
			return chunk.parents.map((p) => {
				return p.isInitial() ? options.entryChunkMultiplicator || 10 : 1;
			}).reduce((a, b) => {
				return a + b;
			}, 0);
		}
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunks-advanced", (chunks) => {
				let combinations = [];
				chunks.forEach((a, idx) => {
					if(a.isInitial()) return;
					for(let i = 0; i < idx; i++) {
						const b = chunks[i];
						if(b.isInitial()) continue;
						combinations.push([b, a]);
					}
				});
 
				combinations.forEach((pair) => {
					const a = pair[0].size({
						chunkOverhead: 0
					});
					const b = pair[1].size({
						chunkOverhead: 0
					});
					const ab = pair[0].integratedSize(pair[1], {
						chunkOverhead: 0
					});
					pair.push({
						a: a,
						b: b,
						ab: ab
					});
					let newSize;
					if(ab === false) {
						pair.unshift(false);
					} else if(options.moveToParents) {
						const aOnly = ab - b;
						const bOnly = ab - a;
						const common = a + b - ab;
						newSize = common + getParentsWeight(pair[0]) * aOnly + getParentsWeight(pair[1]) * bOnly;
						pair.push({
							aOnly: aOnly,
							bOnly: bOnly,
							common: common,
							newSize: newSize
						});
					} else {
						newSize = ab;
					}
 
					pair.unshift((a + b) / newSize);
				});
				combinations = combinations.filter((pair) => {
					return pair[0] !== false;
				});
				combinations.sort((a, b) => {
					return b[0] - a[0];
				});
 
				const pair = combinations[0];
 
				if(!pair) return;
				if(pair[0] < minSizeReduce) return;
 
				if(options.moveToParents) {
					const commonModules = pair[1].modules.filter((m) => {
						return pair[2].modules.indexOf(m) >= 0;
					});
					const aOnlyModules = pair[1].modules.filter((m) => {
						return commonModules.indexOf(m) < 0;
					});
					const bOnlyModules = pair[2].modules.filter((m) => {
						return commonModules.indexOf(m) < 0;
					});
					aOnlyModules.forEach((m) => {
						pair[1].removeModule(m);
						m.removeChunk(pair[1]);
						pair[1].parents.forEach((c) => {
							c.addModule(m);
							m.addChunk(c);
						});
					});
					bOnlyModules.forEach((m) => {
						pair[2].removeModule(m);
						m.removeChunk(pair[2]);
						pair[2].parents.forEach((c) => {
							c.addModule(m);
							m.addChunk(c);
						});
					});
				}
				if(pair[1].integrate(pair[2], "aggressive-merge")) {
					chunks.splice(chunks.indexOf(pair[2]), 1);
					return true;
				}
			});
		});
	}
}
 
module.exports = AggressiveMergingPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js

Statements: 5.38% (7 / 130)      Branches: 0% (0 / 86)      Functions: 0% (0 / 11)      Lines: 5.88% (7 / 119)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194            1   1           1           1           1           1                                                                                                                                                                                                                                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const identifierUtils = require("../util/identifier");
 
function toIndexOf(list) {
	return function(item) {
		return list.indexOf(item);
	};
}
 
function toChunkModuleIndices(modules) {
	return function(idx) {
		return modules[idx];
	};
}
 
function moveModuleBetween(oldChunk, newChunk) {
	return function(module) {
		oldChunk.moveModule(module, newChunk);
	};
}
 
function isNotAEntryModule(entryModule) {
	return function(module) {
		return entryModule !== module;
	};
}
 
function copyWithReason(obj) {
	const newObj = {};
	Object.keys(obj).forEach((key) => {
		newObj[key] = obj[key];
	});
	if(!newObj.reasons || newObj.reasons.indexOf("aggressive-splitted") < 0)
		newObj.reasons = (newObj.reasons || []).concat("aggressive-splitted");
	return newObj;
}
 
class AggressiveSplittingPlugin {
	constructor(options) {
		this.options = options || {};
		if(typeof this.options.minSize !== "number") this.options.minSize = 30 * 1024;
		if(typeof this.options.maxSize !== "number") this.options.maxSize = 50 * 1024;
		if(typeof this.options.chunkOverhead !== "number") this.options.chunkOverhead = 0;
		if(typeof this.options.entryChunkMultiplicator !== "number") this.options.entryChunkMultiplicator = 1;
	}
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunks-advanced", (chunks) => {
				const savedSplits = compilation.records && compilation.records.aggressiveSplits || [];
				const usedSplits = compilation._aggressiveSplittingSplits ?
					savedSplits.concat(compilation._aggressiveSplittingSplits) : savedSplits;
 
				const minSize = this.options.minSize;
				const maxSize = this.options.maxSize;
				// 1. try to restore to recorded splitting
				for(let j = 0; j < usedSplits.length; j++) {
					const splitData = usedSplits[j];
					for(let i = 0; i < chunks.length; i++) {
						const chunk = chunks[i];
						const chunkModuleNames = chunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()));
 
						if(chunkModuleNames.length < splitData.modules.length)
							continue;
						const moduleIndicies = splitData.modules.map(toIndexOf(chunkModuleNames));
						const hasAllModules = moduleIndicies.every((idx) => {
							return idx >= 0;
						});
						if(hasAllModules) {
							if(chunkModuleNames.length > splitData.modules.length) {
								const selectedModules = moduleIndicies.map(toChunkModuleIndices(chunk.modules));
								const newChunk = compilation.addChunk();
								selectedModules.forEach(moveModuleBetween(chunk, newChunk));
								chunk.split(newChunk);
								chunk.name = null;
								newChunk._fromAggressiveSplitting = true;
								if(j < savedSplits.length)
									newChunk._fromAggressiveSplittingIndex = j;
								if(splitData.id !== null && splitData.id !== undefined) {
									newChunk.id = splitData.id;
								}
								newChunk.origins = chunk.origins.map(copyWithReason);
								chunk.origins = chunk.origins.map(copyWithReason);
								return true;
							} else {
								if(j < savedSplits.length)
									chunk._fromAggressiveSplittingIndex = j;
								chunk.name = null;
								if(splitData.id !== null && splitData.id !== undefined) {
									chunk.id = splitData.id;
								}
							}
						}
					}
				}
				// 2. for any other chunk which isn't splitted yet, split it
				for(let i = 0; i < chunks.length; i++) {
					const chunk = chunks[i];
					const size = chunk.size(this.options);
					if(size > maxSize && chunk.modules.length > 1) {
						const newChunk = compilation.addChunk();
						const modules = chunk.modules
							.filter(isNotAEntryModule(chunk.entryModule))
							.sort((a, b) => {
								a = a.identifier();
								b = b.identifier();
								if(a > b) return 1;
								if(a < b) return -1;
								return 0;
							});
						for(let k = 0; k < modules.length; k++) {
							chunk.moveModule(modules[k], newChunk);
							const newSize = newChunk.size(this.options);
							const chunkSize = chunk.size(this.options);
							// break early if it's fine
							if(chunkSize < maxSize && newSize < maxSize && newSize >= minSize && chunkSize >= minSize)
								break;
							if(newSize > maxSize && k === 0) {
								// break if there is a single module which is bigger than maxSize
								break;
							}
							if(newSize > maxSize || chunkSize < minSize) {
								// move it back
								newChunk.moveModule(modules[k], chunk);
								// check if it's fine now
								if(newSize < maxSize && newSize >= minSize && chunkSize >= minSize)
									break;
							}
						}
						if(newChunk.modules.length > 0) {
							chunk.split(newChunk);
							chunk.name = null;
							newChunk.origins = chunk.origins.map(copyWithReason);
							chunk.origins = chunk.origins.map(copyWithReason);
							compilation._aggressiveSplittingSplits = (compilation._aggressiveSplittingSplits || []).concat({
								modules: newChunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()))
							});
							return true;
						} else {
							chunks.splice(chunks.indexOf(newChunk), 1);
						}
					}
				}
			});
			compilation.plugin("record-hash", (records) => {
				// 3. save to made splittings to records
				const minSize = this.options.minSize;
				if(!records.aggressiveSplits) records.aggressiveSplits = [];
				compilation.chunks.forEach((chunk) => {
					if(chunk.hasEntryModule()) return;
					const size = chunk.size(this.options);
					const incorrectSize = size < minSize;
					const modules = chunk.modules.map(m => identifierUtils.makePathsRelative(compiler.context, m.identifier()));
					if(typeof chunk._fromAggressiveSplittingIndex === "undefined") {
						if(incorrectSize) return;
						chunk.recorded = true;
						records.aggressiveSplits.push({
							modules: modules,
							hash: chunk.hash,
							id: chunk.id
						});
					} else {
						const splitData = records.aggressiveSplits[chunk._fromAggressiveSplittingIndex];
						if(splitData.hash !== chunk.hash || incorrectSize) {
							if(chunk._fromAggressiveSplitting) {
								chunk._aggressiveSplittingInvalid = true;
								splitData.invalid = true;
							} else {
								splitData.hash = chunk.hash;
							}
						}
					}
				});
				records.aggressiveSplits = records.aggressiveSplits.filter((splitData) => {
					return !splitData.invalid;
				});
			});
			compilation.plugin("need-additional-seal", (callback) => {
				const invalid = compilation.chunks.some((chunk) => {
					return chunk._aggressiveSplittingInvalid;
				});
				if(invalid)
					return true;
			});
		});
	}
}
module.exports = AggressiveSplittingPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/ChunkModuleIdRangePlugin.js

Statements: 3.45% (1 / 29)      Branches: 0% (0 / 13)      Functions: 0% (0 / 2)      Lines: 3.57% (1 / 28)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57                                                                                                            1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
class ChunkModuleIdRangePlugin {
	constructor(options) {
		this.options = options;
	}
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("module-ids", (modules) => {
				const chunk = this.chunks.filter((chunk) => {
					return chunk.name === options.name;
				})[0];
				if(!chunk) throw new Error("ChunkModuleIdRangePlugin: Chunk with name '" + options.name + "' was not found");
				let currentId = options.start;
				let chunkModules;
				if(options.order) {
					chunkModules = chunk.modules.slice();
					switch(options.order) {
						case "index":
							chunkModules.sort((a, b) => {
								return a.index - b.index;
							});
							break;
						case "index2":
							chunkModules.sort((a, b) => {
								return a.index2 - b.index2;
							});
							break;
						default:
							throw new Error("ChunkModuleIdRangePlugin: unexpected value of order");
					}
 
				} else {
					chunkModules = modules.filter((m) => {
						return m.chunks.indexOf(chunk) >= 0;
					});
				}
 
				for(let i = 0; i < chunkModules.length; i++) {
					const m = chunkModules[i];
					if(m.id === null) {
						m.id = currentId++;
					}
					if(options.end && currentId > options.end)
						break;
				}
			});
		});
	}
}
module.exports = ChunkModuleIdRangePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/CommonsChunkPlugin.js

Statements: 1.44% (2 / 139)      Branches: 0% (0 / 78)      Functions: 0% (0 / 14)      Lines: 1.48% (2 / 135)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364          1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
let nextIdent = 0;
class CommonsChunkPlugin {
	constructor(options) {
		if(arguments.length > 1) {
			throw new Error(`Deprecation notice: CommonsChunkPlugin now only takes a single argument. Either an options
object *or* the name of the chunk.
Example: if your old code looked like this:
	new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')
You would change it to:
	new webpack.optimize.CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.bundle.js' })
The available options are:
	name: string
	names: string[]
	filename: string
	minChunks: number
	chunks: string[]
	children: boolean
	async: boolean
	minSize: number`);
		}
 
		const normalizedOptions = this.normalizeOptions(options);
 
		this.chunkNames = normalizedOptions.chunkNames;
		this.filenameTemplate = normalizedOptions.filenameTemplate;
		this.minChunks = normalizedOptions.minChunks;
		this.selectedChunks = normalizedOptions.selectedChunks;
		this.children = normalizedOptions.children;
		this.async = normalizedOptions.async;
		this.minSize = normalizedOptions.minSize;
		this.ident = __filename + (nextIdent++);
	}
 
	normalizeOptions(options) {
		if(Array.isArray(options)) {
			return {
				chunkNames: options,
			};
		}
 
		if(typeof options === "string") {
			return {
				chunkNames: [options],
			};
		}
 
		// options.children and options.chunk may not be used together
		if(options.children && options.chunks) {
			throw new Error("You can't and it does not make any sense to use \"children\" and \"chunk\" options together.");
		}
 
		/**
		 * options.async and options.filename are also not possible together
		 * as filename specifies how the chunk is called but "async" implies
		 * that webpack will take care of loading this file.
		 */
		if(options.async && options.filename) {
			throw new Error(`You can not specify a filename if you use the \"async\" option.
You can however specify the name of the async chunk by passing the desired string as the \"async\" option.`);
		}
 
		/**
		 * Make sure this is either an array or undefined.
		 * "name" can be a string and
		 * "names" a string or an array
		 */
		const chunkNames = options.name || options.names ? [].concat(options.name || options.names) : undefined;
		return {
			chunkNames: chunkNames,
			filenameTemplate: options.filename,
			minChunks: options.minChunks,
			selectedChunks: options.chunks,
			children: options.children,
			async: options.async,
			minSize: options.minSize
		};
	}
 
	apply(compiler) {
		compiler.plugin("this-compilation", (compilation) => {
			compilation.plugin(["optimize-chunks", "optimize-extracted-chunks"], (chunks) => {
				// only optimize once
				if(compilation[this.ident]) return;
				compilation[this.ident] = true;
 
				/**
				 * Creates a list of "common"" chunks based on the options.
				 * The list is made up of preexisting or newly created chunks.
				 * - If chunk has the name as specified in the chunkNames it is put in the list
				 * - If no chunk with the name as given in chunkNames exists a new chunk is created and added to the list
				 *
				 * These chunks are the "targets" for extracted modules.
				 */
				const targetChunks = this.getTargetChunks(chunks, compilation, this.chunkNames, this.children, this.async);
 
				// iterate over all our new chunks
				targetChunks.forEach((targetChunk, idx) => {
 
					/**
					 * These chunks are subject to get "common" modules extracted and moved to the common chunk
					 */
					const affectedChunks = this.getAffectedChunks(compilation, chunks, targetChunk, targetChunks, idx, this.selectedChunks, this.async, this.children);
 
					// bail if no chunk is affected
					if(!affectedChunks) {
						return;
					}
 
					// If we are async create an async chunk now
					// override the "commonChunk" with the newly created async one and use it as commonChunk from now on
					let asyncChunk;
					if(this.async) {
						asyncChunk = this.createAsyncChunk(compilation, this.async, targetChunk);
						targetChunk = asyncChunk;
					}
 
					/**
					 * Check which modules are "common" and could be extracted to a "common" chunk
					 */
					const extractableModules = this.getExtractableModules(this.minChunks, affectedChunks, targetChunk);
 
					// If the minSize option is set check if the size extracted from the chunk is reached
					// else bail out here.
					// As all modules/commons are interlinked with each other, common modules would be extracted
					// if we reach this mark at a later common chunk. (quirky I guess).
					if(this.minSize) {
						const modulesSize = this.calculateModulesSize(extractableModules);
						// if too small, bail
						if(modulesSize < this.minSize)
							return;
					}
 
					// Remove modules that are moved to commons chunk from their original chunks
					// return all chunks that are affected by having modules removed - we need them later (apparently)
					const chunksWithExtractedModules = this.extractModulesAndReturnAffectedChunks(extractableModules, affectedChunks);
 
					// connect all extracted modules with the common chunk
					this.addExtractedModulesToTargetChunk(targetChunk, extractableModules);
 
					// set filenameTemplate for chunk
					if(this.filenameTemplate)
						targetChunk.filenameTemplate = this.filenameTemplate;
 
					// if we are async connect the blocks of the "reallyUsedChunk" - the ones that had modules removed -
					// with the commonChunk and get the origins for the asyncChunk (remember "asyncChunk === commonChunk" at this moment).
					// bail out
					if(this.async) {
						this.moveExtractedChunkBlocksToTargetChunk(chunksWithExtractedModules, targetChunk);
						asyncChunk.origins = this.extractOriginsOfChunksWithExtractedModules(chunksWithExtractedModules);
						return;
					}
 
					// we are not in "async" mode
					// connect used chunks with commonChunk - shouldnt this be reallyUsedChunks here?
					this.makeTargetChunkParentOfAffectedChunks(affectedChunks, targetChunk);
				});
				return true;
			});
		});
	}
 
	getTargetChunks(allChunks, compilation, chunkNames, children, asyncOption) {
		const asyncOrNoSelectedChunk = children || asyncOption;
 
		// we have specified chunk names
		if(chunkNames) {
			// map chunks by chunkName for quick access
			const allChunksNameMap = allChunks.reduce((map, chunk) => {
				if(chunk.name) {
					map.set(chunk.name, chunk);
				}
				return map;
			}, new Map());
 
			// Ensure we have a chunk per specified chunk name.
			// Reuse existing chunks if possible
			return chunkNames.map(chunkName => {
				if(allChunksNameMap.has(chunkName)) {
					return allChunksNameMap.get(chunkName);
				}
				// add the filtered chunks to the compilation
				return compilation.addChunk(chunkName);
			});
		}
 
		// we dont have named chunks specified, so we just take all of them
		if(asyncOrNoSelectedChunk) {
			return allChunks;
		}
 
		/**
		 * No chunk name(s) was specified nor is this an async/children commons chunk
		 */
		throw new Error(`You did not specify any valid target chunk settings.
Take a look at the "name"/"names" or async/children option.`);
	}
 
	getAffectedChunks(compilation, allChunks, targetChunk, targetChunks, currentIndex, selectedChunks, asyncOption, children) {
		const asyncOrNoSelectedChunk = children || asyncOption;
 
		if(Array.isArray(selectedChunks)) {
			return allChunks.filter(chunk => {
				const notCommmonChunk = chunk !== targetChunk;
				const isSelectedChunk = selectedChunks.indexOf(chunk.name) > -1;
				return notCommmonChunk && isSelectedChunk;
			});
		}
 
		if(asyncOrNoSelectedChunk) {
			// nothing to do here
			if(!targetChunk.chunks) {
				return [];
			}
 
			return targetChunk.chunks.filter((chunk) => {
				// we can only move modules from this chunk if the "commonChunk" is the only parent
				return asyncOption || chunk.parents.length === 1;
			});
		}
 
		/**
		 * past this point only entry chunks are allowed to become commonChunks
		 */
		if(targetChunk.parents.length > 0) {
			compilation.errors.push(new Error("CommonsChunkPlugin: While running in normal mode it's not allowed to use a non-entry chunk (" + targetChunk.name + ")"));
			return;
		}
 
		/**
		 * If we find a "targetchunk" that is also a normal chunk (meaning it is probably specified as an entry)
		 * and the current target chunk comes after that and the found chunk has a runtime*
		 * make that chunk be an 'affected' chunk of the current target chunk.
		 *
		 * To understand what that means take a look at the "examples/chunkhash", this basically will
		 * result in the runtime to be extracted to the current target chunk.
		 *
		 * *runtime: the "runtime" is the "webpack"-block you may have seen in the bundles that resolves modules etc.
		 */
		return allChunks.filter((chunk) => {
			const found = targetChunks.indexOf(chunk);
			if(found >= currentIndex) return false;
			return chunk.hasRuntime();
		});
	}
 
	createAsyncChunk(compilation, asyncOption, targetChunk) {
		const asyncChunk = compilation.addChunk(typeof asyncOption === "string" ? asyncOption : undefined);
		asyncChunk.chunkReason = "async commons chunk";
		asyncChunk.extraAsync = true;
		asyncChunk.addParent(targetChunk);
		targetChunk.addChunk(asyncChunk);
		return asyncChunk;
	}
 
	// If minChunks is a function use that
	// otherwhise check if a module is used at least minChunks or 2 or usedChunks.length time
	getModuleFilter(minChunks, targetChunk, usedChunksLength) {
		if(typeof minChunks === "function") {
			return minChunks;
		}
		const minCount = (minChunks || Math.max(2, usedChunksLength));
		const isUsedAtLeastMinTimes = (module, count) => count >= minCount;
		return isUsedAtLeastMinTimes;
	}
 
	getExtractableModules(minChunks, usedChunks, targetChunk) {
		if(minChunks === Infinity) {
			return [];
		}
 
		// count how many chunks contain a module
		const commonModulesToCountMap = usedChunks.reduce((map, chunk) => {
			for(let module of chunk.modules) {
				const count = map.has(module) ? map.get(module) : 0;
				map.set(module, count + 1);
			}
			return map;
		}, new Map());
 
		// filter by minChunks
		const moduleFilterCount = this.getModuleFilter(minChunks, targetChunk, usedChunks.length);
		// filter by condition
		const moduleFilterCondition = (module, chunk) => {
			if(!module.chunkCondition) {
				return true;
			}
			return module.chunkCondition(chunk);
		};
 
		return Array.from(commonModulesToCountMap).filter(entry => {
			const module = entry[0];
			const count = entry[1];
			// if the module passes both filters, keep it.
			return moduleFilterCount(module, count) && moduleFilterCondition(module, targetChunk);
		}).map(entry => entry[0]);
	}
 
	calculateModulesSize(modules) {
		return modules.reduce((totalSize, module) => totalSize + module.size(), 0);
	}
 
	extractModulesAndReturnAffectedChunks(reallyUsedModules, usedChunks) {
		return reallyUsedModules.reduce((affectedChunksSet, module) => {
			for(let chunk of usedChunks) {
				// removeChunk returns true if the chunk was contained and succesfully removed
				// false if the module did not have a connection to the chunk in question
				if(module.removeChunk(chunk)) {
					affectedChunksSet.add(chunk);
				}
			}
			return affectedChunksSet;
		}, new Set());
	}
 
	addExtractedModulesToTargetChunk(chunk, modules) {
		for(let module of modules) {
			chunk.addModule(module);
			module.addChunk(chunk);
		}
	}
 
	makeTargetChunkParentOfAffectedChunks(usedChunks, commonChunk) {
		for(let chunk of usedChunks) {
			// set commonChunk as new sole parent
			chunk.parents = [commonChunk];
			// add chunk to commonChunk
			commonChunk.addChunk(chunk);
 
			for(let entrypoint of chunk.entrypoints) {
				entrypoint.insertChunk(commonChunk, chunk);
			}
		}
	}
 
	moveExtractedChunkBlocksToTargetChunk(chunks, targetChunk) {
		for(let chunk of chunks) {
			for(let block of chunk.blocks) {
				block.chunks.unshift(targetChunk);
				targetChunk.addBlock(block);
			}
		}
	}
 
	extractOriginsOfChunksWithExtractedModules(chunks) {
		const origins = [];
		for(let chunk of chunks) {
			for(let origin of chunk.origins) {
				const newOrigin = Object.create(origin);
				newOrigin.reasons = (origin.reasons || []).concat("async commons");
				origins.push(newOrigin);
			}
		}
		return origins;
	}
}
 
module.exports = CommonsChunkPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/DedupePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/DedupePlugin.js

Statements: 33.33% (1 / 3)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 33.33% (1 / 3)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                            1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class DedupePlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.warnings.push(new Error("DedupePlugin: This plugin was removed from webpack. Remove it from your configuration."));
		});
	}
}
 
module.exports = DedupePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/EnsureChunkConditionsPlugin.js

Statements: 5% (1 / 20)      Branches: 0% (0 / 10)      Functions: 0% (0 / 1)      Lines: 5.56% (1 / 18)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38                                                                      1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class EnsureChunkConditionsPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => {
				let changed = false;
				chunks.forEach((chunk) => {
					chunk.modules.slice().forEach((module) => {
						if(!module.chunkCondition) return;
						if(!module.chunkCondition(chunk)) {
							const usedChunks = module._EnsureChunkConditionsPlugin_usedChunks = (module._EnsureChunkConditionsPlugin_usedChunks || []).concat(chunk);
							const newChunks = [];
							chunk.parents.forEach((parent) => {
								if(usedChunks.indexOf(parent) < 0) {
									parent.addModule(module);
									newChunks.push(parent);
								}
							});
							module.rewriteChunkInReasons(chunk, newChunks);
							chunk.removeModule(module);
							changed = true;
						}
					});
				});
				if(changed) return true;
			});
		});
	}
}
module.exports = EnsureChunkConditionsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/FlagIncludedChunksPlugin.js

Statements: 6.67% (1 / 15)      Branches: 0% (0 / 8)      Functions: 0% (0 / 1)      Lines: 9.09% (1 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37                                                                    1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class FlagIncludedChunksPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunk-ids", (chunks) => {
				chunks.forEach((chunkA) => {
					chunks.forEach((chunkB) => {
						// as we iterate the same iterables twice
						// skip if we find ourselves
						if(chunkA === chunkB) return;
 
						// instead of swapping A and B just bail
						// as we loop twice the current A will be B and B then A
						if(chunkA.modules.length < chunkB.modules.length) return;
 
						if(chunkB.modules.length === 0) return;
 
						// is chunkB in chunkA?
						for(let i = 0; i < chunkB.modules.length; i++) {
							if(chunkA.modules.indexOf(chunkB.modules[i]) < 0) return;
						}
						chunkA.ids.push(chunkB.id);
					});
				});
			});
		});
	}
}
module.exports = FlagIncludedChunksPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/LimitChunkCountPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/LimitChunkCountPlugin.js

Statements: 3.03% (1 / 33)      Branches: 0% (0 / 21)      Functions: 0% (0 / 2)      Lines: 3.45% (1 / 29)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                                                                                    1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class LimitChunkCountPlugin {
	constructor(options) {
		if(options !== undefined && typeof options !== "object" || Array.isArray(options)) {
			throw new Error("Argument should be an options object.\nFor more info on options, see https://webpack.js.org/plugins/");
		}
		this.options = options || {};
	}
	apply(compiler) {
		const options = this.options;
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunks-advanced", (chunks) => {
				const maxChunks = options.maxChunks;
				if(!maxChunks) return;
				if(maxChunks < 1) return;
				if(chunks.length <= maxChunks) return;
 
				if(chunks.length > maxChunks) {
					const sortedExtendedPairCombinations = chunks.reduce((combinations, a, idx) => {
						// create combination pairs
						for(let i = 0; i < idx; i++) {
							const b = chunks[i];
							combinations.push([b, a]);
						}
						return combinations;
					}, []).map((pair) => {
						// extend combination pairs with size and integrated size
						const a = pair[0].size(options);
						const b = pair[1].size(options);
						const ab = pair[0].integratedSize(pair[1], options);
						return [a + b - ab, ab, pair[0], pair[1], a, b];
					}).filter((extendedPair) => {
						// filter pairs that do not have an integratedSize
						// meaning they can NOT be integrated!
						return extendedPair[1] !== false;
					}).sort((a, b) => { // sadly javascript does an inplace sort here
						// sort them by size
						const diff = b[0] - a[0];
						if(diff !== 0) return diff;
						return a[1] - b[1];
					});
 
					const pair = sortedExtendedPairCombinations[0];
 
					if(pair && pair[2].integrate(pair[3], "limit")) {
						chunks.splice(chunks.indexOf(pair[3]), 1);
						return true;
					}
				}
			});
		});
	}
}
module.exports = LimitChunkCountPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/MergeDuplicateChunksPlugin.js

Statements: 12.5% (2 / 16)      Branches: 0% (0 / 8)      Functions: 0% (0 / 2)      Lines: 13.33% (2 / 15)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35            1                                                   1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
function getChunkIdentifier(chunk) {
	return chunk.modules.map((m) => {
		return m.identifier();
	}).sort().join(", ");
}
 
class MergeDuplicateChunksPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunks-basic", (chunks) => {
				const map = {};
				chunks.slice().forEach((chunk) => {
					if(chunk.hasRuntime() || chunk.hasEntryModule()) return;
					const ident = getChunkIdentifier(chunk);
					if(map[ident]) {
						if(map[ident].integrate(chunk, "duplicate"))
							chunks.splice(chunks.indexOf(chunk), 1);
						return;
					}
					map[ident] = chunk;
				});
			});
		});
	}
}
module.exports = MergeDuplicateChunksPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/MinChunkSizePlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/MinChunkSizePlugin.js

Statements: 3.13% (1 / 32)      Branches: 0% (0 / 10)      Functions: 0% (0 / 2)      Lines: 3.33% (1 / 30)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                                                                                                                                1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class MinChunkSizePlugin {
	constructor(options) {
		if(typeof options !== "object" || Array.isArray(options)) {
			throw new Error("Argument should be an options object.\nFor more info on options, see https://webpack.js.org/plugins/");
		}
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		const minChunkSize = options.minChunkSize;
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-chunks-advanced", (chunks) => {
				const equalOptions = {
					chunkOverhead: 1,
					entryChunkMultiplicator: 1
				};
 
				const sortedSizeFilteredExtendedPairCombinations = chunks.reduce((combinations, a, idx) => {
					// create combination pairs
					for(let i = 0; i < idx; i++) {
						const b = chunks[i];
						combinations.push([b, a]);
					}
					return combinations;
				}, []).filter((pair) => {
					// check if one of the chunks sizes is smaller than the minChunkSize
					const p0SmallerThanMinChunkSize = pair[0].size(equalOptions) < minChunkSize;
					const p1SmallerThanMinChunkSize = pair[1].size(equalOptions) < minChunkSize;
					return p0SmallerThanMinChunkSize || p1SmallerThanMinChunkSize;
				}).map((pair) => {
					// extend combination pairs with size and integrated size
					const a = pair[0].size(options);
					const b = pair[1].size(options);
					const ab = pair[0].integratedSize(pair[1], options);
					return [a + b - ab, ab, pair[0], pair[1]];
				}).filter((pair) => {
					// filter pairs that do not have an integratedSize
					// meaning they can NOT be integrated!
					return pair[1] !== false;
				}).sort((a, b) => { // sadly javascript does an inplace sort here
					// sort by size
					const diff = b[0] - a[0];
					if(diff !== 0) return diff;
					return a[1] - b[1];
				});
 
				if(sortedSizeFilteredExtendedPairCombinations.length === 0) return;
 
				const pair = sortedSizeFilteredExtendedPairCombinations[0];
 
				pair[2].integrate(pair[3], "min-size");
				chunks.splice(chunks.indexOf(pair[3]), 1);
				return true;
			});
		});
	}
}
module.exports = MinChunkSizePlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/OccurrenceOrderPlugin.js

Statements: 6.38% (6 / 94)      Branches: 0% (0 / 52)      Functions: 0% (0 / 7)      Lines: 8.22% (6 / 73)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118                                  1                 1                     1                                                                   1               1                                                                       1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class OccurrenceOrderPlugin {
	constructor(preferEntry) {
		if(preferEntry !== undefined && typeof preferEntry !== "boolean") {
			throw new Error("Argument should be a boolean.\nFor more info on this plugin, see https://webpack.js.org/plugins/");
		}
		this.preferEntry = preferEntry;
	}
	apply(compiler) {
		const preferEntry = this.preferEntry;
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin("optimize-module-order", (modules) => {
				function entryChunks(m) {
					return m.chunks.map((c) => {
						const sum = (c.isInitial() ? 1 : 0) + (c.entryModule === m ? 1 : 0);
						return sum;
					}).reduce((a, b) => {
						return a + b;
					}, 0);
				}
 
				function occursInEntry(m) {
					if(typeof m.__OccurenceOrderPlugin_occursInEntry === "number") return m.__OccurenceOrderPlugin_occursInEntry;
					const result = m.reasons.map((r) => {
						if(!r.module) return 0;
						return entryChunks(r.module);
					}).reduce((a, b) => {
						return a + b;
					}, 0) + entryChunks(m);
					return m.__OccurenceOrderPlugin_occursInEntry = result;
				}
 
				function occurs(m) {
					if(typeof m.__OccurenceOrderPlugin_occurs === "number") return m.__OccurenceOrderPlugin_occurs;
					const result = m.reasons.map((r) => {
						if(!r.module) return 0;
						return r.module.chunks.length;
					}).reduce((a, b) => {
						return a + b;
					}, 0) + m.chunks.length + m.chunks.filter((c) => {
						return c.entryModule === m;
					}).length;
					return m.__OccurenceOrderPlugin_occurs = result;
				}
				modules.sort((a, b) => {
					if(preferEntry) {
						const aEntryOccurs = occursInEntry(a);
						const bEntryOccurs = occursInEntry(b);
						if(aEntryOccurs > bEntryOccurs) return -1;
						if(aEntryOccurs < bEntryOccurs) return 1;
					}
					const aOccurs = occurs(a);
					const bOccurs = occurs(b);
					if(aOccurs > bOccurs) return -1;
					if(aOccurs < bOccurs) return 1;
					if(a.identifier() > b.identifier()) return 1;
					if(a.identifier() < b.identifier()) return -1;
					return 0;
				});
				// TODO refactor to Map
				modules.forEach((m) => {
					m.__OccurenceOrderPlugin_occursInEntry = undefined;
					m.__OccurenceOrderPlugin_occurs = undefined;
				});
			});
			compilation.plugin("optimize-chunk-order", (chunks) => {
				function occursInEntry(c) {
					if(typeof c.__OccurenceOrderPlugin_occursInEntry === "number") return c.__OccurenceOrderPlugin_occursInEntry;
					const result = c.parents.filter((p) => {
						return p.isInitial();
					}).length;
					return c.__OccurenceOrderPlugin_occursInEntry = result;
				}
 
				function occurs(c) {
					return c.blocks.length;
				}
				chunks.forEach((c) => {
					c.modules.sort((a, b) => {
						if(a.identifier() > b.identifier()) return 1;
						if(a.identifier() < b.identifier()) return -1;
						return 0;
					});
				});
				chunks.sort((a, b) => {
					const aEntryOccurs = occursInEntry(a);
					const bEntryOccurs = occursInEntry(b);
					if(aEntryOccurs > bEntryOccurs) return -1;
					if(aEntryOccurs < bEntryOccurs) return 1;
					const aOccurs = occurs(a);
					const bOccurs = occurs(b);
					if(aOccurs > bOccurs) return -1;
					if(aOccurs < bOccurs) return 1;
					if(a.modules.length > b.modules.length) return -1;
					if(a.modules.length < b.modules.length) return 1;
					for(let i = 0; i < a.modules.length; i++) {
						if(a.modules[i].identifier() > b.modules[i].identifier()) return -1;
						if(a.modules[i].identifier() < b.modules[i].identifier()) return 1;
					}
					return 0;
				});
				// TODO refactor to Map
				chunks.forEach((c) => {
					c.__OccurenceOrderPlugin_occursInEntry = undefined;
				});
			});
		});
	}
}
 
module.exports = OccurrenceOrderPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/RemoveEmptyChunksPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/RemoveEmptyChunksPlugin.js

Statements: 14.29% (1 / 7)      Branches: 0% (0 / 3)      Functions: 0% (0 / 1)      Lines: 16.67% (1 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                        1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class RemoveEmptyChunksPlugin {
 
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => {
				chunks.filter((chunk) => chunk.isEmpty() && !chunk.hasRuntime() && !chunk.hasEntryModule())
					.forEach((chunk) => {
						chunk.remove("empty");
						chunks.splice(chunks.indexOf(chunk), 1);
					});
			});
		});
	}
}
module.exports = RemoveEmptyChunksPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/RemoveParentModulesPlugin.js

Statements: 9.09% (5 / 55)      Branches: 0% (0 / 24)      Functions: 0% (0 / 5)      Lines: 10% (5 / 50)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93            1                   1               1                                     1                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
function chunkContainsModule(chunk, module) {
	const chunks = module.chunks;
	const modules = chunk.modules;
	if(chunks.length < modules.length) {
		return chunks.indexOf(chunk) >= 0;
	} else {
		return modules.indexOf(module) >= 0;
	}
}
 
function hasModule(chunk, module, checkedChunks) {
	if(chunkContainsModule(chunk, module)) return [chunk];
	if(chunk.parents.length === 0) return false;
	return allHaveModule(chunk.parents.filter((c) => {
		return checkedChunks.indexOf(c) < 0;
	}), module, checkedChunks);
}
 
function allHaveModule(someChunks, module, checkedChunks) {
	if(!checkedChunks) checkedChunks = [];
	var chunks = [];
	for(var i = 0; i < someChunks.length; i++) {
		checkedChunks.push(someChunks[i]);
		var subChunks = hasModule(someChunks[i], module, checkedChunks);
		if(!subChunks) return false;
 
		for(var index = 0; index < subChunks.length; index++) {
			var item = subChunks[index];
 
			if(!chunks.length || chunks.indexOf(item) < 0) {
				chunks.push(item);
			}
		}
	}
	return chunks;
}
 
function debugIds(chunks) {
	var list = [];
	for(var i = 0; i < chunks.length; i++) {
		var debugId = chunks[i].debugId;
 
		if(typeof debugId !== "number") {
			return "no";
		}
 
		list.push(debugId);
	}
 
	list.sort();
	return list.join(",");
}
 
class RemoveParentModulesPlugin {
	apply(compiler) {
		compiler.plugin("compilation", (compilation) => {
			compilation.plugin(["optimize-chunks-basic", "optimize-extracted-chunks-basic"], (chunks) => {
				for(var index = 0; index < chunks.length; index++) {
					var chunk = chunks[index];
					if(chunk.parents.length === 0) continue;
 
					// TODO consider Map when performance has improved https://gist.github.com/sokra/b36098368da7b8f6792fd7c85fca6311
					var cache = Object.create(null);
					var modules = chunk.modules.slice();
					for(var i = 0; i < modules.length; i++) {
						var module = modules[i];
 
						var dId = debugIds(module.chunks);
						var parentChunksWithModule;
						if((dId in cache) && dId !== "no") {
							parentChunksWithModule = cache[dId];
						} else {
							parentChunksWithModule = cache[dId] = allHaveModule(chunk.parents, module);
						}
						if(parentChunksWithModule) {
							module.rewriteChunkInReasons(chunk, parentChunksWithModule);
							chunk.removeModule(module);
						}
					}
				}
			});
		});
	}
}
module.exports = RemoveParentModulesPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/UglifyJsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/optimize/UglifyJsPlugin.js

Statements: 5.33% (8 / 150)      Branches: 0% (0 / 97)      Functions: 0% (0 / 2)      Lines: 5.76% (8 / 139)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238            1 1 1 1 1 1 1                                                                                                                                                                                                                                                                                                                                                                                                                                                             1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
const SourceMapConsumer = require("source-map").SourceMapConsumer;
const SourceMapSource = require("webpack-sources").SourceMapSource;
const RawSource = require("webpack-sources").RawSource;
const ConcatSource = require("webpack-sources").ConcatSource;
const RequestShortener = require("../RequestShortener");
const ModuleFilenameHelpers = require("../ModuleFilenameHelpers");
const uglify = require("uglify-js");
 
class UglifyJsPlugin {
	constructor(options) {
		if(typeof options !== "object" || Array.isArray(options)) options = {};
		if(typeof options.compressor !== "undefined") options.compress = options.compressor;
		this.options = options;
	}
 
	apply(compiler) {
		const options = this.options;
		options.test = options.test || /\.js($|\?)/i;
		const warningsFilter = options.warningsFilter || (() => true);
 
		const requestShortener = new RequestShortener(compiler.context);
		compiler.plugin("compilation", (compilation) => {
			if(options.sourceMap) {
				compilation.plugin("build-module", (module) => {
					// to get detailed location info about errors
					module.useSourceMap = true;
				});
			}
			compilation.plugin("optimize-chunk-assets", (chunks, callback) => {
				const files = [];
				chunks.forEach((chunk) => files.push.apply(files, chunk.files));
				files.push.apply(files, compilation.additionalChunkAssets);
				const filterdFiles = files.filter(ModuleFilenameHelpers.matchObject.bind(undefined, options));
				filterdFiles.forEach((file) => {
					const oldWarnFunction = uglify.AST_Node.warn_function;
					const warnings = [];
					let sourceMap;
					try {
						const asset = compilation.assets[file];
						if(asset.__UglifyJsPlugin) {
							compilation.assets[file] = asset.__UglifyJsPlugin;
							return;
						}
						let input;
						let inputSourceMap;
						if(options.sourceMap) {
							if(asset.sourceAndMap) {
								const sourceAndMap = asset.sourceAndMap();
								inputSourceMap = sourceAndMap.map;
								input = sourceAndMap.source;
							} else {
								inputSourceMap = asset.map();
								input = asset.source();
							}
							sourceMap = new SourceMapConsumer(inputSourceMap);
							uglify.AST_Node.warn_function = (warning) => { // eslint-disable-line camelcase
								const match = /\[.+:([0-9]+),([0-9]+)\]/.exec(warning);
								const line = +match[1];
								const column = +match[2];
								const original = sourceMap.originalPositionFor({
									line: line,
									column: column
								});
								if(!original || !original.source || original.source === file) return;
								if(!warningsFilter(original.source)) return;
								warnings.push(warning.replace(/\[.+:([0-9]+),([0-9]+)\]/, "") +
									"[" + requestShortener.shorten(original.source) + ":" + original.line + "," + original.column + "]");
							};
						} else {
							input = asset.source();
							uglify.AST_Node.warn_function = (warning) => { // eslint-disable-line camelcase
								warnings.push(warning);
							};
						}
						uglify.base54.reset();
						let ast = uglify.parse(input, {
							filename: file
						});
						if(options.compress !== false) {
							ast.figure_out_scope();
							const compress = uglify.Compressor(options.compress || {
								warnings: false
							}); // eslint-disable-line new-cap
							ast = compress.compress(ast);
						}
						if(options.mangle !== false) {
							ast.figure_out_scope(options.mangle || {});
							ast.compute_char_frequency(options.mangle || {});
							ast.mangle_names(options.mangle || {});
							if(options.mangle && options.mangle.props) {
								uglify.mangle_properties(ast, options.mangle.props);
							}
						}
						const output = {};
						output.comments = Object.prototype.hasOwnProperty.call(options, "comments") ? options.comments : /^\**!|@preserve|@license/;
						output.beautify = options.beautify;
						for(let k in options.output) {
							output[k] = options.output[k];
						}
						const extractedComments = [];
						if(options.extractComments) {
							const condition = {};
							if(typeof options.extractComments === "string" || options.extractComments instanceof RegExp) {
								// extractComments specifies the extract condition and output.comments specifies the preserve condition
								condition.preserve = output.comments;
								condition.extract = options.extractComments;
							} else if(Object.prototype.hasOwnProperty.call(options.extractComments, "condition")) {
								// Extract condition is given in extractComments.condition
								condition.preserve = output.comments;
								condition.extract = options.extractComments.condition;
							} else {
								// No extract condition is given. Extract comments that match output.comments instead of preserving them
								condition.preserve = false;
								condition.extract = output.comments;
							}
 
							// Ensure that both conditions are functions
							["preserve", "extract"].forEach(key => {
								switch(typeof condition[key]) {
									case "boolean":
										var b = condition[key];
										condition[key] = () => b;
										break;
									case "function":
										break;
									case "string":
										if(condition[key] === "all") {
											condition[key] = () => true;
											break;
										}
										var regex = new RegExp(condition[key]);
										condition[key] = (astNode, comment) => regex.test(comment.value);
										break;
									default:
										regex = condition[key];
										condition[key] = (astNode, comment) => regex.test(comment.value);
								}
							});
 
							// Redefine the comments function to extract and preserve
							// comments according to the two conditions
							output.comments = (astNode, comment) => {
								if(condition.extract(astNode, comment)) {
									extractedComments.push(
										comment.type === "comment2" ? "/*" + comment.value + "*/" : "//" + comment.value
									);
								}
								return condition.preserve(astNode, comment);
							};
						}
						let map;
						if(options.sourceMap) {
							map = uglify.SourceMap({ // eslint-disable-line new-cap
								file: file,
								root: ""
							});
							output.source_map = map; // eslint-disable-line camelcase
						}
						const stream = uglify.OutputStream(output); // eslint-disable-line new-cap
						ast.print(stream);
						if(map) map = map + "";
						const stringifiedStream = stream + "";
						let outputSource = (map ?
							new SourceMapSource(stringifiedStream, file, JSON.parse(map), input, inputSourceMap) :
							new RawSource(stringifiedStream));
						if(extractedComments.length > 0) {
							let commentsFile = options.extractComments.filename || file + ".LICENSE";
							if(typeof commentsFile === "function") {
								commentsFile = commentsFile(file);
							}
 
							// Write extracted comments to commentsFile
							const commentsSource = new RawSource(extractedComments.join("\n\n") + "\n");
							if(commentsFile in compilation.assets) {
								// commentsFile already exists, append new comments...
								if(compilation.assets[commentsFile] instanceof ConcatSource) {
									compilation.assets[commentsFile].add("\n");
									compilation.assets[commentsFile].add(commentsSource);
								} else {
									compilation.assets[commentsFile] = new ConcatSource(
										compilation.assets[commentsFile], "\n", commentsSource
									);
								}
							} else {
								compilation.assets[commentsFile] = commentsSource;
							}
 
							// Add a banner to the original file
							if(options.extractComments.banner !== false) {
								let banner = options.extractComments.banner || "For license information please see " + commentsFile;
								if(typeof banner === "function") {
									banner = banner(commentsFile);
								}
								if(banner) {
									outputSource = new ConcatSource(
										"/*! " + banner + " */\n", outputSource
									);
								}
							}
						}
						asset.__UglifyJsPlugin = compilation.assets[file] = outputSource;
						if(warnings.length > 0) {
							compilation.warnings.push(new Error(file + " from UglifyJs\n" + warnings.join("\n")));
						}
					} catch(err) {
						if(err.line) {
							const original = sourceMap && sourceMap.originalPositionFor({
								line: err.line,
								column: err.col
							});
							if(original && original.source) {
								compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message + " [" + requestShortener.shorten(original.source) + ":" + original.line + "," + original.column + "][" + file + ":" + err.line + "," + err.col + "]"));
							} else {
								compilation.errors.push(new Error(file + " from UglifyJs\n" + err.message + " [" + file + ":" + err.line + "," + err.col + "]"));
							}
						} else if(err.msg) {
							compilation.errors.push(new Error(file + " from UglifyJs\n" + err.msg));
						} else
							compilation.errors.push(new Error(file + " from UglifyJs\n" + err.stack));
					} finally {
						uglify.AST_Node.warn_function = oldWarnFunction; // eslint-disable-line camelcase
					}
				});
				callback();
			});
		});
	}
}
 
module.exports = UglifyJsPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/

Statements: 16% (12 / 75)      Branches: 0% (0 / 18)      Functions: 0% (0 / 5)      Lines: 16.9% (12 / 71)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/performance/
File Statements Branches Functions Lines
AssetsOverSizeLimitWarning.js 30% (3 / 10) 100% (0 / 0) 0% (0 / 1) 33.33% (3 / 9)
EntrypointsOverSizeLimitWarning.js 27.27% (3 / 11) 100% (0 / 0) 0% (0 / 1) 30% (3 / 10)
NoAsyncChunksWarning.js 33.33% (2 / 6) 100% (0 / 0) 0% (0 / 1) 33.33% (2 / 6)
SizeLimitsPlugin.js 8.33% (4 / 48) 0% (0 / 18) 0% (0 / 2) 8.7% (4 / 46)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/AssetsOverSizeLimitWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/AssetsOverSizeLimitWarning.js

Statements: 30% (3 / 10)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 33.33% (3 / 9)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25            1 1   1                              
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Sean Larkin @thelarkinn
*/
"use strict";
 
const WebpackError = require("../WebpackError");
const SizeFormatHelpers = require("../SizeFormatHelpers");
 
module.exports = class AssetsOverSizeLimitWarning extends WebpackError {
	constructor(assetsOverSizeLimit, assetLimit) {
		super();
 
		this.name = "AssetsOverSizeLimitWarning";
		this.assets = assetsOverSizeLimit;
		const assetLists = this.assets.map(asset => `\n  ${asset.name} (${SizeFormatHelpers.formatSize(asset.size)})`).join("");
		this.message = `asset size limit: The following asset(s) exceed the recommended size limit (${SizeFormatHelpers.formatSize(assetLimit)}).
This can impact web performance.
Assets: ${assetLists}`;
 
		Error.captureStackTrace(this, this.constructor);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/EntrypointsOverSizeLimitWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/EntrypointsOverSizeLimitWarning.js

Statements: 27.27% (3 / 11)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 30% (3 / 10)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30            1 1   1                                        
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Sean Larkin @thelarkinn
*/
"use strict";
 
const WebpackError = require("../WebpackError");
const SizeFormatHelpers = require("../SizeFormatHelpers");
 
module.exports = class EntrypointsOverSizeLimitWarning extends WebpackError {
	constructor(entrypoints, entrypointLimit) {
		super();
 
		this.name = "EntrypointsOverSizeLimitWarning";
		this.entrypoints = entrypoints;
		const entrypointList = this.entrypoints.map(entrypoint => `\n  ${
			entrypoint.name
		} (${
			SizeFormatHelpers.formatSize(entrypoint.size)
		})\n${
			entrypoint.files.map(asset => `      ${asset}`).join("\n")
		}`).join("");
		this.message = `entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (${SizeFormatHelpers.formatSize(entrypointLimit)}). This can impact web performance.
Entrypoints:${entrypointList}\n`;
 
		Error.captureStackTrace(this, this.constructor);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/NoAsyncChunksWarning.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/NoAsyncChunksWarning.js

Statements: 33.33% (2 / 6)      Branches: 100% (0 / 0)      Functions: 0% (0 / 1)      Lines: 33.33% (2 / 6)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22            1   1                          
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Sean Larkin @thelarkinn
*/
"use strict";
 
const WebpackError = require("../WebpackError");
 
module.exports = class NoAsyncChunksWarning extends WebpackError {
	constructor() {
		super();
 
		this.name = "NoAsyncChunksWarning";
		this.message = "webpack performance recommendations: \n" +
			"You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.\n" +
			"For more info visit https://webpack.js.org/guides/code-splitting/";
 
		Error.captureStackTrace(this, this.constructor);
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/SizeLimitsPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/performance/SizeLimitsPlugin.js

Statements: 8.33% (4 / 48)      Branches: 0% (0 / 18)      Functions: 0% (0 / 2)      Lines: 8.7% (4 / 46)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104          1 1 1   1                                                                                                                                                                                            
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Sean Larkin @thelarkinn
*/
"use strict";
const EntrypointsOverSizeLimitWarning = require("./EntrypointsOverSizeLimitWarning");
const AssetsOverSizeLimitWarning = require("./AssetsOverSizeLimitWarning");
const NoAsyncChunksWarning = require("./NoAsyncChunksWarning");
 
module.exports = class SizeLimitsPlugin {
	constructor(options) {
		this.hints = options.hints;
		this.maxAssetSize = options.maxAssetSize;
		this.maxEntrypointSize = options.maxEntrypointSize;
		this.assetFilter = options.assetFilter;
	}
	apply(compiler) {
		const entrypointSizeLimit = this.maxEntrypointSize;
		const assetSizeLimit = this.maxAssetSize;
		const hints = this.hints;
		const assetFilter = this.assetFilter || (asset => !(/\.map$/.test(asset)));
 
		compiler.plugin("after-emit", (compilation, callback) => {
			const warnings = [];
 
			const getEntrypointSize = entrypoint =>
				entrypoint.getFiles()
				.filter(assetFilter)
				.map(file => compilation.assets[file])
				.filter(Boolean)
				.map(asset => asset.size())
				.reduce((currentSize, nextSize) => currentSize + nextSize, 0);
 
			const assetsOverSizeLimit = [];
			Object.keys(compilation.assets)
				.filter(assetFilter)
				.forEach(assetName => {
					const asset = compilation.assets[assetName];
					const size = asset.size();
 
					if(size > assetSizeLimit) {
						assetsOverSizeLimit.push({
							name: assetName,
							size: size,
						});
						asset.isOverSizeLimit = true;
					}
				});
 
			const entrypointsOverLimit = [];
			Object.keys(compilation.entrypoints)
				.forEach(key => {
					const entry = compilation.entrypoints[key];
					const size = getEntrypointSize(entry, compilation);
 
					if(size > entrypointSizeLimit) {
						entrypointsOverLimit.push({
							name: key,
							size: size,
							files: entry.getFiles().filter(assetFilter)
						});
						entry.isOverSizeLimit = true;
					}
				});
 
			if(hints) {
				// 1. Individual Chunk: Size < 250kb
				// 2. Collective Initial Chunks [entrypoint] (Each Set?): Size < 250kb
				// 3. No Async Chunks
				// if !1, then 2, if !2 return
				if(assetsOverSizeLimit.length > 0) {
					warnings.push(
						new AssetsOverSizeLimitWarning(
							assetsOverSizeLimit,
							assetSizeLimit));
				}
				if(entrypointsOverLimit.length > 0) {
					warnings.push(
						new EntrypointsOverSizeLimitWarning(
							entrypointsOverLimit,
							entrypointSizeLimit));
				}
 
				if(warnings.length > 0) {
					const hasAsyncChunks = compilation.chunks.filter(chunk => !chunk.isInitial()).length > 0;
 
					if(!hasAsyncChunks) {
						warnings.push(new NoAsyncChunksWarning());
					}
 
					if(hints === "error") {
						Array.prototype.push.apply(compilation.errors, warnings);
					} else {
						Array.prototype.push.apply(compilation.warnings, warnings);
					}
				}
			}
 
			callback();
		});
	}
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/util/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/util/

Statements: 50% (4 / 8)      Branches: 0% (0 / 2)      Functions: 100% (0 / 0)      Lines: 57.14% (4 / 7)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/util/
File Statements Branches Functions Lines
identifier.js 50% (4 / 8) 0% (0 / 2) 100% (0 / 0) 57.14% (4 / 7)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/util/identifier.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/util/identifier.js

Statements: 50% (4 / 8)      Branches: 0% (0 / 2)      Functions: 100% (0 / 0)      Lines: 57.14% (4 / 7)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18  1   1       1   1                
"use strict";
const path = require("path");
 
const looksLikeAbsolutePath = (maybeAbsolutePath) => {
	return /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);
};
 
const normalizePathSeparator = (p) => p.replace(/\\/g, "/");
 
exports.makePathsRelative = (context, identifier) => {
	return identifier
		.split(/([|! ])/)
		.map(str => looksLikeAbsolutePath(str) ?
			normalizePathSeparator(path.relative(context, str)) : str)
		.join("");
};
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/web/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/web/

Statements: 25% (1 / 4)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 25% (1 / 4)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/lib/web/
File Statements Branches Functions Lines
WebEnvironmentPlugin.js 25% (1 / 4) 100% (0 / 0) 0% (0 / 2) 25% (1 / 4)
Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/web/WebEnvironmentPlugin.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/lib/web/WebEnvironmentPlugin.js

Statements: 25% (1 / 4)      Branches: 100% (0 / 0)      Functions: 0% (0 / 2)      Lines: 25% (1 / 4)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20                                  1    
/*
	MIT License http://www.opensource.org/licenses/mit-license.php
	Author Tobias Koppers @sokra
*/
"use strict";
 
class WebEnvironmentPlugin {
	constructor(inputFileSystem, outputFileSystem) {
		this.inputFileSystem = inputFileSystem;
		this.outputFileSystem = outputFileSystem;
	}
 
	apply(compiler) {
		compiler.outputFileSystem = this.outputFileSystem;
	}
}
 
module.exports = WebEnvironmentPlugin;
 
 
Code coverage report for node-npmtest-webpack/node_modules/webpack/schemas/

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/schemas/

Statements: 33.33% (4 / 12)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 27.27% (3 / 11)      Ignored: none     

All files » node-npmtest-webpack/node_modules/webpack/schemas/
File Statements Branches Functions Lines
ajv.absolutePath.js 33.33% (4 / 12) 0% (0 / 4) 0% (0 / 2) 27.27% (3 / 11)
Code coverage report for node-npmtest-webpack/node_modules/webpack/schemas/ajv.absolutePath.js

npmtest-webpack (v0.0.3)

Code coverage report for node-npmtest-webpack/node_modules/webpack/schemas/ajv.absolutePath.js

Statements: 33.33% (4 / 12)      Branches: 0% (0 / 4)      Functions: 0% (0 / 2)      Lines: 27.27% (3 / 11)      Ignored: none     

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31    1                       1       1                        
"use strict";
 
const getErrorFor = (shouldBeAbsolute, data, schema) => {
	const message = shouldBeAbsolute ?
		`The provided value ${JSON.stringify(data)} is not an absolute path!`
		: `A relative path is expected. However the provided value ${JSON.stringify(data)} is an absolute path!`;
 
	return {
		keyword: "absolutePath",
		params: { absolutePath: data },
		message: message,
		parentSchema: schema,
	};
};
module.exports = (ajv) => ajv.addKeyword("absolutePath", {
	errors: true,
	type: "string",
	compile(expected, schema) {
		function callback(data) {
			const passes = expected === /^(?:[A-Za-z]:\\|\/)/.test(data);
			if(!passes) {
				callback.errors = [getErrorFor(expected, data, schema)];
			}
			return passes;
		}
		callback.errors = [];
		return callback;
	}
});